제출 #1353300

#제출 시각아이디문제언어결과실행 시간메모리
1353300putuputu지구 온난화 (NOI13_gw)C++20
40 / 40
267 ms12612 KiB
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<pair<int, int>> p;
    for(int i=0; i<n; i++){
        p.push_back({a[i], i});
    }
    p.push_back({-1, n+1});
    int ans=0, ans1=0;
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    vector<bool> t(n+1, false);
    for(int i=0; i<n; i++){
        t[p[i].second]=true;
        int cnt=0;
        if(t[p[i].second+1]==true){
            cnt++;
        }
        if(t[p[i].second-1]==true){
            cnt++;
        }
        if(cnt==0){
            ans++;
        }
        if(cnt==2){
            ans--;
        }
        if(p[i].first!=p[i+1].first and p[i+1].first!=-1){
            ans1=max(ans, ans1);
        }
    }
    cout << ans1;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…