Submission #82842

# Submission time Handle Problem Language Result Execution time Memory
82842 2018-11-02T05:34:07 Z mra2322001 Global Warming (NOI13_gw) C++14
19 / 40
297 ms 33560 KB
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
#define left le

using namespace std;
typedef long long ll;
const int N = 1e6 + 2;

int n, left[N];
vector <pair <int, int> > a;

int get1(int u){
    if(left[u]==-1) return -1;
    if(left[u]==u) return u;
    left[u] = get1(left[u]);
    return left[u];
}

int main(){
    ios_base::sync_with_stdio(0);

    cin >> n;
    f1(i, n){
        int x; cin >> x;
        a.emplace_back(x, i);
        left[i] = -1;
    }
    sort(a.begin(), a.end(), greater <pair <int, int> > ());
    int cur = 0, res = 0;
    for(int i = 0; i < n; i++){
        int j = i;
        if(a[i].first==0) continue;
        for(j = i; j < n; j++){
            if(a[j].first != a[i].first) break;
            int u = a[j].second;
            left[u] = u;
            int k1 = get1(u - 1), k2 = get1(u + 1);
            if(k1 > 0 && k2 > 0){
                left[k2] = k1;
                left[u] = k1;
                cur--;
            }
            else if(k2 > 0){
                left[k2] = u;
            }
            else if(k1 > 0){
                left[u] = k1;
            }
            else cur++;
        }
        res = max(res, cur);
        i = j - 1;
    }
    cout << res;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 472 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2300 KB Output is correct
2 Correct 24 ms 2552 KB Output is correct
3 Correct 24 ms 2800 KB Output is correct
4 Correct 25 ms 3052 KB Output is correct
5 Correct 28 ms 3328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 4108 KB Output is correct
2 Correct 28 ms 4816 KB Output is correct
3 Correct 29 ms 5468 KB Output is correct
4 Correct 28 ms 6540 KB Output is correct
5 Correct 27 ms 7264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 24132 KB Output is correct
2 Correct 296 ms 24280 KB Output is correct
3 Runtime error 297 ms 33508 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 295 ms 33560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
2 Halted 0 ms 0 KB -