Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
32813 LYLAKIOIAKIOI 【S】T1 C++ 通过 100 483 MS 43220 KB 697 2024-10-02 12:35:36

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int N=1500,V=5500; int n,m; int a[N]; int f[N][V]; int cost[V]; int main(){ cin>>n>>m;int ma=0; for(int i=1;i<=n;i++) cin>>a[i],ma=max(ma,a[i]);sort(a+1,a+n+1); int it=0;for(int i=0;i<=m;i++){ while(it<n&&a[it+1]<=i) it++; cost[i]=it;//cout<<cost[i]<<' '; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ for(int k=0;k<=min(ma+2,j);k++){ f[i][j]=max(f[i][j],f[i-1][j-k]+cost[k]); } } }//cout<<f[n][m]<<' '; int res=0;for(int i=1;i<=m;i++) res=max(res,f[n][i]); printf("%.12Lf",(long double)(n*n-res)/n); return 0; }


测评信息: