제출 #786562

#제출 시각아이디문제언어결과실행 시간메모리
786562Dan4LifeSeesaw (JOI22_seesaw)C++17
0 / 100
1 ms340 KiB
#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]; int cnt2 = 10; for(int i = max(0, n/2-5); i < n and cnt2--; i++){ //cout << i << ": "; int cnt = 10; for(int j = max(i,n/2); j < n and cnt--; j++){ double L = (pr[j+1]-pr[i])/(j-i+1); ans = min(ans, chk(L)-L); //cout << chk(L)-L << " "; }//cout <<"\n"; } cout << fixed << setprecision(9) << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...