Alex_tz307

IOIT Hill Climb

Nov 16th, 2020 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. inline void max_self(int &a, int b) {
  6.     a = max(a, b);
  7. }
  8.  
  9. int main() {
  10.     ios_base::sync_with_stdio(false);
  11.     cin.tie(nullptr);
  12.     cout.tie(nullptr);
  13.     int T;
  14.     cin >> T;
  15.     while(T--) {
  16.         int N;
  17.         cin >> N;
  18.         vector < int > a(N + 1);
  19.         for(int i = 1; i <= N; ++i)
  20.             cin >> a[i];
  21.         vector < int > dp(N + 1);
  22.         int ans = 0;
  23.         for(int i = N - 1; i > 0; --i)
  24.             if(a[i] < a[i + 1]) {
  25.                 dp[i] = dp[i + 1] + 1;
  26.                 a[i] = a[i + 1];
  27.                 max_self(ans, dp[i]);
  28.             }
  29.         cout << ans << '\n';
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment