fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(nullptr); // Optimizes input/output operations
  9.  
  10. int T;
  11. cin >> T;
  12.  
  13. while (T--) {
  14. int N;
  15. cin >> N;
  16.  
  17. vector<int> arr(N);
  18. for (int i = 0; i < N; ++i) {
  19. cin >> arr[i];
  20. }
  21.  
  22. int max_so_far = arr[N - 1];
  23. int count = 1;
  24.  
  25. for (int i = N - 2; i >= 0; --i) {
  26. if (arr[i] > max_so_far) {
  27. ++count;
  28. max_so_far = arr[i];
  29. }
  30. }
  31.  
  32. cout << count << '\n';
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5320KB
stdin
1
6
16 17 4 3 5 2
stdout
3