Submission

Status:

[PPPP][P][P][P][P]

Subtask/Task Score:

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

Score: 100

User: speed_coding

Problemset: นก

Language: cpp

Time: 0.003 second

Submitted On: 2026-09-18 13:32:09

#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int box[n];
	for (int i = 0; i<n; i++){
		cin>>box[i];
    }
    /*for (int i = 0; i<n; i++){
		cout<<box[i]<<" ";
    }*/
    int ans =0;
	for (int i = 0; i<n; i++){
        if (i==0){
            if(box[i]>box[i+1]){
                ans+=1;
            }
        }
        else if (i==n-1){
            if(box[i]>box[i-1]){
                ans+=1;
            }
        }
		else if (box[i]>box[i-1] && box[i] > box[i+1]){
            ans += 1;
        }
	}
    cout << ans << "\n";
}