Submission #969050

#TimeUsernameProblemLanguageResultExecution timeMemory
969050happy_nodeSeesaw (JOI22_seesaw)C++17
34 / 100
2 ms604 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX=105; int N; int A[MX]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>N; for(int i=1;i<=N;i++) cin>>A[i]; vector<double> v; for(int l=1;l<=N;l++) { ll sum=0; for(int r=l;r<=N;r++) { sum+=A[r]; v.push_back((double)sum/(r-l+1)); } } sort(v.begin(),v.end()); ll sum=0; for(int i=1;i<=N;i++) sum+=A[i]; double ans=2e9; for(auto x:v) { ll l=1,r=N,s=sum,k=N; double mx=(double)s/k; if(mx<x) continue; while(l<r) { double av=(double)(s-A[r])/(k-1); if(av>=x) { mx=max(mx,av); s-=A[r]; k--; r--; } else { av=(double)(s-A[l])/(k-1); mx=max(mx,av); s-=A[l]; k--; l++; } } ans=min(ans,mx-x); } cout<<fixed<<setprecision(10)<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...