제출 #1353254

#제출 시각아이디문제언어결과실행 시간메모리
1353254gvancak지구 온난화 (NOI13_gw)C++20
17 / 40
163 ms31604 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const ll mod=1e9+7;
const ll N=1e6;
ll a[N+5],b[N+5],l,r,x,y,z,ans,t,n,q,mx,mn,k;
bool ok,okk;
pair <ll,ll> p[N+5];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    t=1;
    
    cin >> n;
    for (int i=1; i<=n; i++) {
    cin >> a[i];
	p[i]=mp(a[i],i);
    }
    sort(p+1,p+n+1);
    ans=1; ll cur=1;
    //b[0]=1; b[n+1]=1;
    for (int i=1; i<=n; i++){
    	
    	ll ind=p[i].s;
    	b[ind]=1;
    	
    	if (ind!=1 && ind!=n && b[ind-1]==1 && b[ind+1]==1) cur--;
    	else
    	if (ind!=1 && ind!=n && b[ind-1]==0 && b[ind+1]==0) cur++;
		if (p[i].f!=p[i+1].f)
		ans=max(ans,cur); 
    	//cout << i << " " << ans << endl;
    	
	}
	cout << ans << endl;
    
    

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