제출 #1355668

#제출 시각아이디문제언어결과실행 시간메모리
1355668jfioashfn333지구 온난화 (NOI13_gw)C++20
19 / 40
57 ms22268 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define pp pop_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define r0 return 0
using namespace std;
const int N = 9 * 1e5 + 5, B = 2 * 1e9 ,M = 5005, mod = 1e9 + 7;
int n,m,k;
int a[N],vis[N];
vector <pii> p;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        p.pb({a[i],i});
    }
    sort(all(p));
    reverse(all(p));
    int cur = 0,ans = 0;
    for (int i = 0; i < n; i++) {
        int l = p[i].ss - 1, r = p[i].ss + 1;
        cur++;
        if (vis[l] == 1) cur--;
        if (vis[r] == 1) cur--;
        vis[p[i].ss] = 1;
        if (p[i + 1].ff != p[i].ff or i + 1 == n) {
            ans = max(ans,cur);
        }
    }
    cout << ans << endl;
    return 0;
}

#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…