Advertisement
momo2345

magical indices

Jul 22nd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define sunil ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
  4. int main()
  5. {
  6.     //sunil;
  7.     int t; cin>>t;
  8.      while(t--)
  9.     {
  10.         int n;
  11.         int c=0;
  12.         scanf("%d",&n);
  13.         int a[n];
  14.         for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  15.         for(int i=3;i<=n;i++){
  16.             if(a[i]>=a[i-1] && a[i-1]>=a[i-2]) c++;
  17.         }
  18.        printf("%d\n",c);
  19.         c=0;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement