Submission #751920

# Submission time Handle Problem Language Result Execution time Memory
751920 2023-06-01T19:47:57 Z AndiR Global Warming (NOI13_gw) C++14
40 / 40
554 ms 18840 KB
#include <iostream>
#include <algorithm>

using namespace std;
const int Nmax=1000000;

struct island{
    int h, t;
}e[Nmax*2+5];
int n, v[Nmax+1];
bool cmp(island a, island b){
    return a.h<b.h;
}
int main()
{
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>v[i];
    int mx=0, nris=0;
    for (int i=0; i<n; i++){
        if (mx<v[i])
            mx=v[i];
        if (v[i]<mx && v[i]<v[i+1]){
            e[nris*2].t=1; e[nris*2].h=v[i];
            e[nris*2+1].t=-1; e[nris*2+1].h=mx;
            mx=0;
            nris++;
        }
    }
    e[nris*2].t=-1; e[nris*2].h=mx;
    sort(e, e+nris*2+1, cmp);
    int crt=1, i=0; mx=1;
    while(i<=nris*2){
        while (e[i].h==e[i+1].h){
            crt+=e[i].t;
            i++;
        }
        crt+=e[i].t;
        if (crt>mx)
            mx=crt;
        i++;
    }
    cout<<mx;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1208 KB Output is correct
2 Correct 18 ms 1468 KB Output is correct
3 Correct 18 ms 1380 KB Output is correct
4 Correct 18 ms 1356 KB Output is correct
5 Correct 18 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1112 KB Output is correct
2 Correct 38 ms 1492 KB Output is correct
3 Correct 40 ms 1148 KB Output is correct
4 Correct 40 ms 1992 KB Output is correct
5 Correct 38 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 437 ms 9412 KB Output is correct
2 Correct 426 ms 18744 KB Output is correct
3 Correct 435 ms 18836 KB Output is correct
4 Correct 428 ms 18840 KB Output is correct
5 Correct 403 ms 18028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 9488 KB Output is correct
2 Correct 554 ms 9428 KB Output is correct
3 Correct 436 ms 9384 KB Output is correct
4 Correct 195 ms 9292 KB Output is correct
5 Correct 204 ms 12176 KB Output is correct