QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#301642#5475. Make a LoopwxhtzdyWA 4ms1704kbC++20548b2024-01-10 03:57:592024-01-10 03:57:59

Judging History

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

  • [2024-01-10 03:57:59]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:1704kb
  • [2024-01-10 03:57:59]
  • 提交

answer

#include <stdio.h>

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

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

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1516kb

input:

4
1 1 1 1

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1484kb

input:

6
1 3 1 3 1 3

output:

Yes

result:

ok single line: 'Yes'

Test #3:

score: 0
Accepted
time: 0ms
memory: 1520kb

input:

6
2 2 1 1 1 1

output:

No

result:

ok single line: 'No'

Test #4:

score: 0
Accepted
time: 0ms
memory: 1488kb

input:

8
99 98 15 10 10 5 2 1

output:

Yes

result:

ok single line: 'Yes'

Test #5:

score: 0
Accepted
time: 4ms
memory: 1704kb

input:

100
9384 9699 9434 9482 9525 39 26 9314 9610 9698 79 9558 9398 9358 9389 52 9395 286 9401 9449 9511 219 9291 9 9384 117 9344 98 9341 32 9375 8893 9414 9434 9412 9699 370 9363 9458 9639 9517 9347 9427 9357 9688 9456 9394 9455 9818 9436 9436 9228 9372 9345 9746 9540 9404 9475 9482 9535 9404 9400 28 91...

output:

No

result:

ok single line: 'No'

Test #6:

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

input:

100
9398 9394 9457 9626 9490 104 9431 9403 9440 9360 9429 9483 9400 9371 9377 9275 9448 9491 9445 9408 9401 59 129 9396 9877 9241 9439 707 9454 9717 9484 9407 9472 9483 47 83 9535 9289 9509 243 9365 132 9352 9496 9571 9439 9365 9456 9924 9479 28 227 17 9358 9494 9311 9342 9300 9434 9731 9886 9654 94...

output:

No

result:

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