답안 #1030054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030054 2024-07-21T17:42:00 Z jnjwnwnw 지구 온난화 (NOI13_gw) C++17
19 / 40
1000 ms 65536 KB
#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];
map<ll, ll> cntOf, curCnt;

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());
    // fff(i, 0, n){
    //     cout << v[i].first << " " << v[i].second << endl;
    // } cout << endl;
    ll best = 0;
    ll cur = 0;
    fff(i, 0, n){
        auto [h, j] = v[i];
        curCnt[h]++;
        sim[j] = 1;
        cur++;
        if (sim[j+1]) cur--;
        if (sim[j-1]) cur--;
        if (curCnt[h] == cntOf[h] && cur > best) best = cur;
    }
    cout << best << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2764 KB Output is correct
2 Correct 22 ms 2764 KB Output is correct
3 Correct 24 ms 2768 KB Output is correct
4 Correct 23 ms 2768 KB Output is correct
5 Correct 23 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 15288 KB Output is correct
2 Correct 87 ms 15264 KB Output is correct
3 Correct 115 ms 15212 KB Output is correct
4 Correct 97 ms 15260 KB Output is correct
5 Correct 93 ms 15296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 916 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1040 ms 64024 KB Time limit exceeded
2 Halted 0 ms 0 KB -