Submission #1353277

#TimeUsernameProblemLanguageResultExecution timeMemory
1353277vako_pGlobal Warming (NOI13_gw)C++20
40 / 40
127 ms12172 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define pb push_back
#define ff first
#define sd second
#define debug(x) cerr << #x << " ----> " << x << endl;

const int mxN = 1e6 + 5;
ll n,a[mxN];
pair<ll,ll> b[mxN];

int main(){	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
//		assert(a[i]);
		b[i] = {a[i], i};
	}
	ll ans = 1,curr = 1;
	sort(b + 1, b + n + 1);
	for(int j = 1; j <= n; j++){
		ll i = b[j].sd;
		curr--;
		if(i < n and a[i + 1] >= a[i]) curr++;
		if(i > 1 and a[i - 1] > a[i]) curr++;
		if(j < n and b[j].ff != b[j + 1].ff) ans = max(ans, curr);
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...