QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301567#5475. Make a LoopwxhtzdyRE 1ms3684kbC++20558b2024-01-10 03:29:282024-01-10 03:29:28

Judging History

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

  • [2024-01-10 03:29:28]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3684kb
  • [2024-01-10 03:29:28]
  • 提交

answer

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

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,dp[2][1000005];

int main(){
	n=readint();
	dp[0][0]=1;
	int s=0;
	for(int i=1;i<=n;i++){
		int x=readint();
		s+=x;
		for(int j=s;j>=x;j--){
			for(int f=0;f<2;f++){
				dp[f][j]=min(4,dp[f][j]+dp[f^1][j-x]);
			}
		}
	}
	if(n%2==0&&s%2==0&&dp[s/2][0]>=4) printf("Yes\n"); else printf("No\n");
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3684kb

input:

4
1 1 1 1

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: -100
Runtime Error

input:

6
1 3 1 3 1 3

output:


result: