Advertisement
Saleh127

Untitled

Apr 20th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a[100000],b,c=0,d=1000000,e,f,i,j,k,l;
  6. cin>>b;
  7. for(i=0;i<b;i++)
  8. {
  9. cin>>a[i];
  10. }
  11. for(i=1;i<b;i++)
  12. {
  13. if(a[i]-a[i-1]>c)
  14. {
  15. c=a[i]-a[i-1];
  16. }
  17. }
  18. for(i=2;i<b;i++)
  19. {
  20. if(a[i]-a[i-2]<d)
  21. {
  22. d=a[i]-a[i-2];
  23. }
  24. }
  25. cout<<max(c,d)<<endl;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement