fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define MAX 1000
  4.  
  5. int main()
  6. {
  7. int n,i,j,x=0,res;
  8. vector<int>v;
  9. cin>>n;
  10. int a[MAX];
  11. for(i=1;i<=n;i++)
  12. {
  13. cin>>a[i];
  14. }
  15. for(i=1;i<=n;i++)
  16. {
  17. for(j=1;j<=n;j++)
  18. {
  19. x = abs(a[i]-a[j])+abs(i-j);
  20. v.push_back(x);
  21. }
  22. }
  23. res = *max_element(v.begin(),v.end());
  24. cout<<res;
  25. return 0;
  26. }
Success #stdin #stdout 0s 15224KB
stdin
10
-98 -5 37 -97 38 22 70 42 61 84
stdout
191