| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1353272 | gvancak | Global Warming (NOI13_gw) | C++20 | 141 ms | 31604 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;
pair <ll,ll> p[N+5];
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 (ind==1 && b[2]==1) cur--;
else
if (ind==n && b[n-1]==1) cur--;
if (p[i].f!=p[i+1].f || n==i)
ans=max(ans,cur);
//cout << i << " " << ans << endl;
}
cout << ans << endl;
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
