Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <iomanip>
- #include <map>
- #include <cmath>
- #include <queue>
- #include <cstdlib>
- using namespace std;
- #define pb push_back
- #define ll long long
- int mode = 1000 * 1000 * 1000 + 7;
- int main()
- {
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<double> v(n);
- for(int i = 0; i < n; ++i)
- {
- cin >> v[i];
- }
- sort(v.begin(), v.end());
- vector<double> len(n - 1);
- vector<double> poss;
- double mx = 0;
- for(int i = 0; i < n - 1; ++i)
- {
- len[i] = v[i + 1] - v[i];
- if(len[i] > mx)
- {
- poss.clear();
- mx = len[i];
- poss.pb(i);
- }
- else if(len[i] == mx)
- {
- poss.pb(i);
- }
- }
- cout << setprecision(1) << fixed;
- if(n == 2)
- {
- cout << len[0] / 2 << endl;
- return 0;
- }
- double ans = mx;
- for(int i = 0; i < poss.size(); ++i)
- {
- double ans2 = mx / 2, need = 1;
- for(int j = poss[i] - 1; j >= 0; --j)
- {
- if(ans2 - need < len[j])
- {
- ans2 += len[j] + need;
- }
- ++need;
- }
- need = 1;
- for(int j = poss[i] + 1; j < n - 1; ++j)
- {
- if(ans2 - need < len[j])
- {
- ans2 = need + len[j];
- }
- ++need;
- }
- ans = min(ans, ans2);
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement