Submission

Status:
[PPPP][P][P][P][P]

Score: 100

User: sorawit

Problemset: นก

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-18 13:54:44

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;

    vector<int> H(n);
    for(auto &h:H) cin >> h;

    int cnt =0;

    if(n == 1) cout << 1;
    else {
        for(int i=0;i<n;i++){
            if(i ==0){
                if(H[i+1] < H[i]) cnt++;
            }
            else if (i== n-1){
                if(H[i-1] < H[i]) cnt++;
            }
            else{
                if(H[i-1] < H[i] && H[i+1]<H[i]) cnt++;
            }
        }
        cout << cnt;
    }



}