Advertisement
Guest User

H TAP 2017

a guest
Oct 22nd, 2017
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define dprint(v) cerr << #v"=" << v << endl //;)
  4. #define forr(i,a,b) for(int i=(a); i<(b); i++)
  5. #define forn(i,n) forr(i,0,n)
  6. #define dforn(i,n) for(int i=n-1; i>=0; i--)
  7. #define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
  8. #define sz(c) ((int)c.size())
  9. #define zero(v) memset(v, 0, sizeof(v))
  10. #define pb push_back
  11. #define fst first
  12. #define snd second
  13. typedef long long ll;
  14. typedef pair<int,int> ii;
  15.  
  16. const int MAXN=100100;
  17. int n,v[MAXN],m;
  18.  
  19. int main() {
  20.     //~ freopen("in", "r", stdin);
  21.     ios::sync_with_stdio(0);
  22.     while(cin >> n){
  23.         v[0]=0;
  24.         m = 1;
  25.         forn(i,n) { int a; cin >> a;
  26.             if (a != v[m-1]) {
  27.                 v[m++] = a;
  28.             }
  29.         }
  30.         int ans = 0;
  31.         v[m] = 0;  
  32.         forr(i,1,m) {
  33.             if (v[i-1]<v[i] && v[i]>v[i+1]) ans++;
  34.         }
  35.        
  36.         cout << ans << endl;
  37.     }
  38.     return 0;
  39. }
Advertisement
RAW Paste Data Copied
Advertisement