Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define loop(i,b,e) for(int i=b;i<=e;i++)
- #define loop2(i,e,b) for(int i=e;i>=b;i--)
- #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
- #define fi first
- #define se second
- typedef long long ll;
- typedef unsigned long long ull;
- const int N = 1e6 + 5;
- const ll mod = 1e9 + 7;
- const int oo = 1e9;
- int n;
- ll t[N];
- int main() {
- scanf("%d", &n);
- loop(i, 0, n - 1)
- cin >> t[i];
- if (t[1] - t[0] > t[n - 1] - t[n - 2]) {
- t[0] = 1e18;
- }
- else t[n-1] = 1e18;
- sort(t,t+n);
- ll mx = -1;
- int j = 0;
- loop(i, 1, n - 2) {
- if (t[i] - t[i - 1] > mx) {
- j = i;
- mx = t[i] - t[i - 1];
- }
- }
- t[n-1] = (t[j] + t[j - 1]) / 2;
- sort(t,t+n);
- ll ans = -1;
- loop(i, 1, n - 1)
- ans = max(ans,t[i]-t[i-1]);
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement