delete pics to save space

This commit is contained in:
2023-08-03 09:22:52 +08:00
commit de60cd6ed4
1334 changed files with 66221 additions and 0 deletions

24
p.CH5501.cpp Normal file
View File

@ -0,0 +1,24 @@
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e6+5;
int n,a[maxn],Q[maxn],head,tail;
int main()
{
#ifdef local
freopen("pro.in","r",stdin);
#endif
scanf("%d",&n);
for(int i=1;i<=n;i++) { scanf("%d",&a[i]); a[i+n]=a[i]; }
int res=0;
for(int i=1;i<=n*2;i++)
{
while(head<tail&&Q[head]<i-n/2) head++;
if(head<tail) res=max(res,a[i]+i+a[Q[head]]-Q[head]);
while(head<tail&&a[i]-i>=a[Q[tail-1]]-Q[tail-1]) tail--;
Q[tail++]=i;
}
printf("%d\n",res);
return 0;
}