# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
801799 |
2023-08-02T07:45:24 Z |
ymm |
Seesaw (JOI22_seesaw) |
C++17 |
|
1800 ms |
384 KB |
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
mt19937_64 rd(time(0));
const int N = 200'010;
double pos[N];
double sum;
int n;
double solve(double l)
{
double sum = ::sum;
if (l > sum/n)
return 1;
int p0 = 0, p1 = n-1;
double mn = sum/n, mx = sum/n;
for (int cnt = n; p0 < p1; --cnt) {
if (l <= (sum-pos[p1])/(cnt-1)) {
sum -= pos[p1];
mn = min(mn, sum/(cnt-1));
--p1;
} else {
sum -= pos[p0];
mx = max(mx, sum/(cnt-1));
++p0;
}
}
return mx - mn;
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
Loop (i,0,n) {
ll x;
cin >> x;
pos[i] = (double)x/1e9;
sum += pos[i];
}
double m = sum/n;
double ans = m - pos[0];
while (clock() < 1.8 * CLOCKS_PER_SEC) {
double x = (double)rd()/ULONG_LONG_MAX * (m - pos[0]) + pos[0];
ans = min(ans, solve(x));
}
cout << fixed << setprecision(9);
cout << ans*1e9 << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1800 ms |
308 KB |
Output is correct |
2 |
Correct |
1800 ms |
304 KB |
Output is correct |
3 |
Correct |
1800 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1800 ms |
308 KB |
Output is correct |
2 |
Correct |
1800 ms |
304 KB |
Output is correct |
3 |
Correct |
1800 ms |
308 KB |
Output is correct |
4 |
Correct |
1800 ms |
212 KB |
Output is correct |
5 |
Correct |
1800 ms |
304 KB |
Output is correct |
6 |
Correct |
1800 ms |
308 KB |
Output is correct |
7 |
Correct |
1800 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1800 ms |
308 KB |
Output is correct |
2 |
Correct |
1800 ms |
304 KB |
Output is correct |
3 |
Correct |
1800 ms |
308 KB |
Output is correct |
4 |
Correct |
1800 ms |
212 KB |
Output is correct |
5 |
Correct |
1800 ms |
304 KB |
Output is correct |
6 |
Correct |
1800 ms |
308 KB |
Output is correct |
7 |
Correct |
1800 ms |
308 KB |
Output is correct |
8 |
Incorrect |
1800 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1800 ms |
308 KB |
Output is correct |
2 |
Correct |
1800 ms |
304 KB |
Output is correct |
3 |
Correct |
1800 ms |
308 KB |
Output is correct |
4 |
Correct |
1800 ms |
212 KB |
Output is correct |
5 |
Correct |
1800 ms |
304 KB |
Output is correct |
6 |
Correct |
1800 ms |
308 KB |
Output is correct |
7 |
Correct |
1800 ms |
308 KB |
Output is correct |
8 |
Incorrect |
1800 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |