제출 #1029460

#제출 시각아이디문제언어결과실행 시간메모리
1029460rsinventor지구 온난화 (NOI13_gw)C++17
23 / 40
172 ms22420 KiB
#include <bits/stdc++.h>

using namespace std;

constexpr int MAXN = 1e6 + 42;

bool isl[MAXN];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

//    freopen("warming.in", "r", stdin);
//    freopen("warming.out", "w", stdout);

    int n;
    cin >> n;
    int h[n];
    vector<pair<int, int>> sh2(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
        sh2[i].first = h[i];
        sh2[i].second = i;
    }
    sort(sh2.rbegin(), sh2.rend());

    int mx_islands = 0;
    int islands = 0;
    for(int i = 0; i < n; i++) {
        int s = sh2[i].second;
        islands++;
        isl[s] = true;
        if(isl[s+1]) {
            islands--;
        }
        if(isl[s-1]) {
            islands--;
        }
        if(i==n-1 || sh2[i].first!=sh2[i+1].first) {
            mx_islands = max(mx_islands, islands);
        }
        if(sh2[i].first==20) {
            cout << islands << endl;
        }
    }

    cout << mx_islands << endl;


    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...