Submission #1030059

# Submission time Handle Problem Language Result Execution time Memory
1030059 2024-07-21T18:15:58 Z jnjwnwnw Global Warming (NOI13_gw) C++17
19 / 40
994 ms 65192 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define ll int
#define fff(i, a, b) for(ll i = a; i < b; i++)

#define MAXN 1000006

bool sim[MAXN];
map<ll, ll> cntOf;

int main(){
    ll n; cin >> n;
    vector<pair<ll, ll>> v;
    fff(i, 0, n){
        ll a; cin >> a;
        cntOf[a]++;
        v.emplace_back(a, i+1);
    }
    sort(v.rbegin(), v.rend());

    ll best = 0;
    ll cur = 0;
    fff(i, 0, n){
        auto [h, j] = v[i];
        cntOf[h]--;
        sim[j] = 1;
        cur++;
        if (sim[j+1]) cur--;
        if (sim[j-1]) cur--;
        if (!cntOf[h] && cur > best) best = cur;
    }
    cout << best << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1748 KB Output is correct
2 Correct 22 ms 1744 KB Output is correct
3 Correct 22 ms 1744 KB Output is correct
4 Correct 21 ms 1748 KB Output is correct
5 Correct 22 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 6592 KB Output is correct
2 Correct 48 ms 6588 KB Output is correct
3 Correct 65 ms 6596 KB Output is correct
4 Correct 65 ms 6624 KB Output is correct
5 Correct 61 ms 6608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 994 ms 65192 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 801 ms 44720 KB Memory limit exceeded
2 Halted 0 ms 0 KB -