제출 #1353296

#제출 시각아이디문제언어결과실행 시간메모리
1353296lizi14지구 온난화 (NOI13_gw)C++20
6 / 40
1098 ms131072 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define ss second
#define ina insert
#define pb push_back
signed main(){
    int n;
    cin>>n;
    int x[n];
    set<int>s;
    map<int,vector<int>>mp;
    for(int i=0; i<n; i++){
        cin>>x[i];
        s.ina(x[i]);
        mp[x[i]].pb(i);
    }
    int ans=1;
    set<int>bati;
    int l=0;
    for(auto a:s){
        int di=0,ri=0;
        for(auto b:mp[a]){
            if(bati.find(b-1)==bati.end())di=1;
            if(bati.find(b+1)==bati.end())ri=1;
            if(di && ri){
                bati.ina(b);
                if(b!=0 && b!=n-1)l++;
            }
            else{
                if(di!=1 && ri!=1){
                    l--;
                }
                else bati.ina(b);
            }
            //cout<<l<<" ";
            //bati.ina(b);
        }
        //cout<<endl;
        // cout<<l<<endl;
        // for(auto t:bati){
        //     cout<<t<<" ";
        // }
        // cout<<endl;
        
        // if(bati.find(n-1)!=bati.end() && bati.find(0)!=bati.end()){
        //     ans=max(l+1,ans);
        // }
        // else ans=max(l,ans);
        //if(l==1)continue;
        if(bati.size()==n-1){
            continue;
        }
        ans=max(l+1,ans);
    }
    cout<<ans<<endl;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…