/ CYOJ /

记录详情

Accepted


  
Found 20 testcases.
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 5ms 384.0 KiB
#2 Accepted 15ms 768.0 KiB
#3 Accepted 3ms 384.0 KiB
#4 Accepted 6ms 512.0 KiB
#5 Accepted 38ms 1.117 MiB
#6 Accepted 3ms 512.0 KiB
#7 Accepted 10ms 768.0 KiB
#8 Accepted 28ms 896.0 KiB
#9 Accepted 9ms 640.0 KiB
#10 Accepted 8ms 640.0 KiB
#11 Accepted 6ms 640.0 KiB
#12 Accepted 2ms 256.0 KiB
#13 Accepted 28ms 1.0 MiB
#14 Accepted 3ms 512.0 KiB
#15 Accepted 3ms 512.0 KiB
#16 Accepted 14ms 768.0 KiB
#17 Accepted 12ms 768.0 KiB
#18 Accepted 3ms 384.0 KiB
#19 Accepted 4ms 384.0 KiB
#20 Accepted 16ms 768.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
int a[105];
int n,sum=0;
bool dp[105][10005];
int main()
{
	cin>>n;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	dp[0][0]=true;
	for(int i=1;i<=n;i++)
		for(int j=i;j>=1;j--)
			for (int k=sum;k>=a[i];k--)
				dp[j][k]|=dp[j-1][k-a[i]];
	sum/=2,n/=2;
	for(int i=sum;i>=0;i--)
		if(dp[n][i])
		{
			cout<<i<<endl;
			break;
		}
    return 0;
}

信息

递交者
类型
递交
题目
P1014 准备
语言
C++
递交时间
2022-08-29 17:56:43
评测时间
2022-08-29 17:56:43
评测机
分数
100
总耗时
225ms
峰值内存
1.117 MiB