Submission

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

Score: 100

User: Pera

Problemset: นก

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-27 11:30:17

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    if (n == 1) {
        cout << 1 << '\n';
        return 0;
    }

    int count {0};
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            if (h[i] > h[i + 1]) {
                count++;
            }
        } else if (i == n - 1) {
            if (h[i] > h[i - 1]) {
                count++;
            }
        } else {
            if (h[i] > h[i - 1] && h[i] > h[i + 1]) {
                count++;
            }
        }

    }

    cout << count << '\n';
}