QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#301602 | #5475. Make a Loop | wxhtzdy | WA | 0ms | 1572kb | C++20 | 500b | 2024-01-10 03:44:32 | 2024-01-10 03:44:33 |
Judging History
answer
#include <stdio.h>
int min(int a, int b) { return a < b ? a : b; }
int n,x,s,a[100],dp[2][500005];
int main(){
scanf("%d",&n);
for(int i=0,s=0;i<n;i++) scanf("%d",a+i),s+=a[i];
dp[0][0]=1;
int ns=0;
for(int i=1;i<=n;i++){
ns+=x;
ns=min(ns,s/2);
for(int j=ns;j>=x;j--){
dp[0][j]=min(4,dp[0][j]+dp[1][j-x]);
dp[1][j]=min(4,dp[1][j]+dp[0][j-x]);
}
}
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: 1552kb
input:
4 1 1 1 1
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 0ms
memory: 1572kb
input:
6 1 3 1 3 1 3
output:
Yes
result:
ok single line: 'Yes'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 1556kb
input:
6 2 2 1 1 1 1
output:
Yes
result:
wrong answer 1st lines differ - expected: 'No', found: 'Yes'