fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define db double
  5. const int N=1e5;
  6. int main () {
  7. ll n; cin>>n;
  8. ll a[n],x;
  9. vector <ll> b;
  10.  
  11. for(int i=0;i<n;i++) cin>>a[i];
  12. for (int i=0;i<n-1;i++){
  13. x=abs(a[i]-a[i+1]);
  14. b.push_back(x);
  15. }
  16. int k=0;
  17. for (int i=0;i<n;i++) {
  18. // cout<<b[i]<<" ";
  19. if (b[i]>k) k=b[i];
  20. // if (k<a[i]) k=a[i];
  21. }
  22.  
  23. cout<<k;
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5316KB
stdin
6
1 7 5 4 10 1
stdout
9