sonprao

001

Oct 23rd, 2018
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,i,maxb,maxc,minb,minc,b[1000005],c[1000005],a[1000005];
  4. int main(){
  5.     cin>>n;
  6.     maxb=-INT_MAX;
  7.     maxc=-INT_MAX;
  8.     minb=INT_MAX;
  9.     minc=INT_MAX;
  10.     for (i=1;i<=n;i++) cin>>a[i];
  11.     for (i=1;i<=n;i++) {b[i]=a[i]+i; {if (b[i]>maxb) maxb=b[i]; if (b[i]<minb) minb=b[i];} }
  12.     for (i=1;i<=n;i++) {c[i]=a[i]-i; {if (c[i]>maxc) maxc=c[i]; if (c[i]<minc) minc=c[i];} }
  13.     cout<<max(maxb-minb,maxc-minc);
  14.     return 0;
  15. }
RAW Paste Data