Submission

Status:

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

Subtask/Task Score:

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

Score: 100

User: Kidmaiok

Problemset: นก

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-13 13:29:59

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define space << ' '
#define nl << endl

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    vector<int> tree;
    cin >> n;
    for(int i =0; i < n; i++){
        int x;
        cin >> x;
        tree.push_back(x);
    }
    int count = 0;
    for(int i =0; i < n; i++){
        if(i == 0){
            if(tree[i+1] < tree[i]){
                count++;
            }
        }else if(i == n-1){
            if(tree[i-1] < tree[i]){
                count++;
            }
        }else{
            if(tree[i-1] < tree[i] && tree[i+1] < tree[i]){
                count++;
            }
        }
    }
    cout << count;
    
}