Submission #1029461

# Submission time Handle Problem Language Result Execution time Memory
1029461 2024-07-20T22:52:49 Z rsinventor Global Warming (NOI13_gw) C++17
40 / 40
157 ms 15952 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1628 KB Output is correct
2 Correct 13 ms 1908 KB Output is correct
3 Correct 12 ms 1884 KB Output is correct
4 Correct 12 ms 1892 KB Output is correct
5 Correct 13 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1628 KB Output is correct
2 Correct 8 ms 1628 KB Output is correct
3 Correct 13 ms 1652 KB Output is correct
4 Correct 13 ms 1648 KB Output is correct
5 Correct 12 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 12956 KB Output is correct
2 Correct 135 ms 13136 KB Output is correct
3 Correct 144 ms 12956 KB Output is correct
4 Correct 142 ms 13136 KB Output is correct
5 Correct 139 ms 12976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 12972 KB Output is correct
2 Correct 140 ms 13136 KB Output is correct
3 Correct 139 ms 13140 KB Output is correct
4 Correct 133 ms 13136 KB Output is correct
5 Correct 134 ms 15952 KB Output is correct