fork download
  1. //haha
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define XD 1000000007
  6.  
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);
  11. cout.tie(0);
  12.  
  13. int t;
  14. cin >> t;
  15. while(t--)
  16. {
  17. int n;
  18. cin >> n;
  19. int a[105];
  20. for(int i = 1; i <= n; ++i)
  21. cin >> a[i];
  22.  
  23. int f[105][105][105] = {-1};
  24. for(int i = n; i >= 1; --i)
  25. {
  26. for(int j = 0; j <= n ; ++j)
  27. {
  28. for(int q = 0; q <= n; ++q)
  29. {
  30. int ans = f[i+1][j][q];
  31. if(j == 0 or a[i] > a[j])
  32. ans = max(ans, 1 + f[i + 1][i][q]);
  33. if(q == 0 or a[i] > a[q])
  34. ans = max(ans, 1 + f[i + 1][j][i]);
  35.  
  36. f[i][j][q] = ans;
  37. }
  38. }
  39. }
  40.  
  41. cout << f[1][0][0] << endl;
  42. }
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5276KB
stdin
sadasdasdsa
stdout
Standard output is empty