fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. ll n;
  10. cin >> n;
  11. vector<ll> a;
  12. a.push_back(-INF);
  13. for(int i=0;i<n;i++){
  14. int x;cin >> x;
  15. if(x==a.back()) continue;
  16. a.push_back(x);
  17. }
  18. a.push_back(-INF);
  19. int ans = 0;
  20. for(int i=1;i<a.size()-1;i++){
  21. if(a[i]>a[i-1] && a[i]>a[i+1]) ans++;
  22. }
  23. cout << ans << '\n';
  24. }
  25. int main(){
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28.  
  29. int t;
  30. cin >> t;
  31. while (t--) solve();
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5316KB
stdin
4
5
4 3 2 1 5
3
1 1 1
6
7 8 1 5 9 2
10
1 7 9 7 1 10 2 10 10 7
stdout
2
1
2
3