QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#284145 | #2884. 切切糕 | qyzyq# | WA | 1ms | 38432kb | C++14 | 662b | 2023-12-16 10:57:46 | 2023-12-16 10:57:47 |
Judging History
answer
#include<bits/stdc++.h>
#define db double
using namespace std;
const int N=2510;
int n,m,a[N],suf[N];
db f[N][N];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1; i<=n; i++)
scanf("%d",&a[i]);
sort(a+1,a+1+n);
f[0][0]=0;
for(int i=1; i<=n; i++)
{
int cur=n-i+1;
f[i][0]=(db)a[cur]+f[i-1][0];
f[i][i]=(db)a[cur]/2.000000+f[i-1][i-1];
for(int j=1; j<=min(i-1,m); j++)
f[i][j]=(f[i-1][j-1]+f[i-1][j]+(db)a[cur])/2.000000;
}
// cout<<f[2][2]<<endl;
db ans=1e9;
for(int i=0; i<=m; i++)
/*printf("%.3lf ",f[n][i]),*/ans=min(ans,f[n][i]);
printf("%.6lf\n",f[n][m]);
return 0;
}
/*
4 3
4 3 2 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3880kb
input:
1 1 10
output:
5.000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
10 8 1 2 3 1 2 2 1 3 3 2
output:
10.035156
result:
ok found '10.0351560', expected '10.0351562', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 38432kb
input:
2500 1 1 1 2 1 4 1 5 1 2 2 3 4 2 3 4 3 4 1 4 5 3 5 4 4 1 3 3 3 5 5 5 3 2 2 3 2 3 2 1 1 5 4 2 1 3 4 3 4 2 3 1 1 2 2 2 4 3 1 1 4 2 2 4 3 5 4 2 3 1 1 4 3 3 4 3 1 2 1 1 2 2 4 4 3 3 2 5 4 2 4 5 4 5 3 1 5 1 3 3 1 1 3 5 3 5 1 1 4 3 5 2 4 1 5 2 1 3 3 1 1 5 2 1 3 4 1 2 4 2 2 2 3 5 1 1 3 1 1 5 1 2 3 3 5 4 4 5...
output:
7446.000000
result:
wrong answer 1st numbers differ - expected: '7442.0000000', found: '7446.0000000', error = '0.0005375'