Submission

Status:

[PPP-][P][P][P][P]

Subtask/Task Score:

{0/20}{20/20}{20/20}{20/20}{20/20}

Score: 80

User: I_am_me

Problemset: นก

Language: cpp

Time: 0.004 second

Submitted On: 2026-01-02 19:39:18

#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] ;
    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;
}