# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
786546 |
2023-07-18T09:01:14 Z |
Dan4Life |
Seesaw (JOI22_seesaw) |
C++17 |
|
66 ms |
788 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)1e3+10;
int n;
double a[mxN], pr[mxN], dp[mxN][mxN];
const double INF = 1e18;
double chk(double L){
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
dp[i][j] = INF;
}
}
for(int i = 0; i < n; i++)
if(a[i]>=L) dp[i][i] = a[i];
for(int l = 2; l <= n; l++){
for(int i = 0; i+l-1 < n; i++){
int j = i+l-1;
if(pr[j+1]-pr[i] < L*(j-i+1)) continue;
dp[i][j] = (pr[j+1]-pr[i])/(j-i+1);
dp[i][j] = max(dp[i][j], min(dp[i+1][j],dp[i][j-1]));
}
}
return dp[0][n-1];
}
int main()
{
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
sort(a,a+n); double ans = a[n-1]-a[0];
for(int i = 0; i < n; i++) pr[i+1] = pr[i]+a[i];
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
double L = (pr[j+1]-pr[i])/(j-i+1);
ans = min(ans, chk(L)-L);
}
}
cout << fixed << setprecision(9) << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
57 ms |
692 KB |
Output is correct |
5 |
Correct |
58 ms |
788 KB |
Output is correct |
6 |
Correct |
56 ms |
788 KB |
Output is correct |
7 |
Correct |
66 ms |
784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
57 ms |
692 KB |
Output is correct |
5 |
Correct |
58 ms |
788 KB |
Output is correct |
6 |
Correct |
56 ms |
788 KB |
Output is correct |
7 |
Correct |
66 ms |
784 KB |
Output is correct |
8 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
57 ms |
692 KB |
Output is correct |
5 |
Correct |
58 ms |
788 KB |
Output is correct |
6 |
Correct |
56 ms |
788 KB |
Output is correct |
7 |
Correct |
66 ms |
784 KB |
Output is correct |
8 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |