Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define loop(i,b,e) for(int i=b;i<=e;i++)
  4. #define loop2(i,e,b) for(int i=e;i>=b;i--)
  5. #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  6. #define fi first
  7. #define se second
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10. const int N = 1e6 + 5;
  11. const ll mod = 1e9 + 7;
  12. const int oo = 1e9;
  13.  
  14. int n;
  15. ll t[N];
  16.  
  17. int main() {
  18.     scanf("%d", &n);
  19.     loop(i, 0, n - 1)
  20.         cin >> t[i];
  21.     if (t[1] - t[0] > t[n - 1] - t[n - 2]) {
  22.         t[0] = 1e18;
  23.     }
  24.     else t[n-1] = 1e18;
  25.     sort(t,t+n);
  26.     ll mx = -1;
  27.     int j = 0;
  28.     loop(i, 1, n - 2) {
  29.         if (t[i] - t[i - 1] > mx) {
  30.             j = i;
  31.             mx = t[i] - t[i - 1];
  32.         }
  33.     }
  34.     t[n-1] = (t[j] + t[j - 1]) / 2;
  35.     sort(t,t+n);
  36.     ll ans = -1;
  37.     loop(i, 1, n - 1)
  38.         ans = max(ans,t[i]-t[i-1]);
  39.     cout << ans;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement