제출 #1352445

#제출 시각아이디문제언어결과실행 시간메모리
1352445kawhiet지구 온난화 (NOI13_gw)C++20
0 / 40
129 ms8268 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<array<int, 2>> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i][0];
        h[i][1] = i;
    }
    sort(h.rbegin(), h.rend());
    vector<bool> vis(n);
    int ans = 0, s = 0;
    for (int i = 0; i < n; i++) {
        int x = h[i][0];
        while (i + 1 < n && h[i + 1][0] == x) {
            int j = h[i][1];
            bool ok = true;
            if (j > 0 && vis[j - 1]) ok = false;
            if (j + 1 < n && vis[j + 1]) ok = false;
            if (ok) {
                s++;
            }
            if (j > 0 && j < n - 1 && vis[j - 1] && vis[j + 1]) {
                s--;
            }
            vis[j] = 1;
            i++;
        }
        ans = max(ans, s);
    }
    cout << ans << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...