Submission #1030062

#TimeUsernameProblemLanguageResultExecution timeMemory
1030062jnjwnwnw지구 온난화 (NOI13_gw)C++17
40 / 40
364 ms26520 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

#define MAXN 1000006

bool sim[MAXN];

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

    ll best = 0;
    ll cur = 0;
    ll prev = -1;
    fff(i, 0, n){
        auto [h, j] = v[i];
        if (prev != h && cur > best) best = cur;
        sim[j] = 1;
        cur++;
        if (sim[j+1]) cur--;
        if (sim[j-1]) cur--;
        prev = h;
    }
    cout << best << endl;
}
#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...