QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#284167#2884. 切切糕qyzyq#WA 0ms3944kbC++14922b2023-12-16 11:22:482023-12-16 11:22:48

Judging History

你现在查看的是最新测评结果

  • [2023-12-16 11:22:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3944kb
  • [2023-12-16 11:22:48]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
using namespace std;

const int N=2510;
const db eps=1e-12;

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++)
		{
			db x=(db)a[cur]-(f[i-1][j-1]-f[i-1][j]);
			db y=(db)a[cur]-x;
			if(y<x)
				f[i][j]=min(x+f[i-1][j-1],y+f[i-1][j]);
			else
			{
				if((db)x>=0)
					f[i][j]=(f[i-1][j-1]+f[i-1][j]+(db)a[cur])/2.000000;
				else
					f[i][j]=min(f[i-1][j-1],f[i-1][j]+(db)a[cur]);
			}
		}

	}
	// 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: 0ms
memory: 3888kb

input:

1 1
10

output:

5.000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3944kb

input:

10 8
1 2 3 1 2 2 1 3 3 2

output:

4.750000

result:

wrong answer 1st numbers differ - expected: '10.0351562', found: '4.7500000', error = '0.5266641'