QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301656#5475. Make a LoopwxhtzdyWA 0ms1524kbC++20571b2024-01-10 04:07:412024-01-10 04:07:42

Judging History

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

  • [2024-01-10 04:07:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1524kb
  • [2024-01-10 04:07:41]
  • 提交

answer

#include <stdio.h>

signed char min(signed char a, signed char b) { return a < b ? a : b; }

int n,s,i,j;
short int a[101];
signed char dp[2][500005];

int main(){
scanf("%d",&n);
s=0;
for(i=1;i<=n;i++) scanf("%hd",a+i),s+=a[i];
if(s%2==1){
printf("No");
return 0;
}
s>>=1;
	dp[0][0]=1;
	int ns=0;
	for(i=1;i<=n;i++){
		ns+=a[i];
if(ns>s) ns=s;
		for(j=ns;j>=a[i];j--){
			
				dp[0][j]=min(4,dp[0][j]+dp[1][j-a[i]]);
				dp[1][j]=min(4,dp[1][j]+dp[0][j-a[i]]);
		}
	}
	if(n%2==1||dp[0][s/2]<4) printf("No"); else printf("Yes");
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1524kb

input:

4
1 1 1 1

output:

No

result:

wrong answer 1st lines differ - expected: 'Yes', found: 'No'