Submission
Status:
[PPPP][P][P][P][P]
Subtask/Task Score:
{20/20}{20/20}{20/20}{20/20}{20/20}
Score: 100
User: I_am_me
Problemset: นก
Language: cpp
Time: 0.004 second
Submitted On: 2026-01-02 19:42:31
#include <bits/stdc++.h>
using namespace std;
int ans = 0;
void check(int h1, int h2, int h3){
if (h2>h1 && h2>h3) ans++;
return;
} ;
int main(){
int n;
cin>>n ;
vector<int> htree(n) ;
for(int i = 0;i<n;i++) cin>>htree[i] ;
if (n==1) cout<<1;
else {for(int i = 1;i<n-1;i++) check(htree[i-1],htree[i],htree[i+1]) ;
if (htree[0]>htree[1]) ans++ ;
if (htree[n-1]>htree[n-2]) ans++ ;
cout<<ans ;}
return 0;
}