QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185958 | #5475. Make a Loop | luanmenglei | WA | 8ms | 35060kb | C++17 | 1.2kb | 2023-09-22 21:39:07 | 2023-09-22 21:39:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define y second
#define mp make_pair
#define pii pair<int,int>
#define pll pair<LL,LL>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define LL long long
#define x first
#define pb push_back
#define pi acosl(-1)
#define sqr(x) ((x)*(x))
const int mod=998244353;
LL dp[1000005][2];
LL dp2[1000005][2];
int a[100000];
void solve(int T){
memset(dp, 0, sizeof(dp));
memset(dp2, 0, sizeof(dp2));
int n;
scanf("%d",&n);
for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
if(n%2==1){
printf("No\n");
return;
}
dp[0][0]=1;
int Max=0;
for(int i = 1;i<=n;i++){
int r = a[i];
Max+=r;
for(int j =r;j<=Max;j++){
dp2[j][0]+=dp[j-r][1];
dp2[j][1]+=dp[j-r][0];
}
if(i==1)dp[0][0]=0;
for(int j = 0;j<=Max;j++){
for(int k = 0;k<2;k++)dp[j][k]+=dp2[j][k],dp2[j][k]=0;
}
}
if(Max%2==0&&dp[Max/2][0]>=2){
printf("Yes\n");
}
else{
printf("No\n");
}
}
int main(){
int t=1;
scanf("%d",&t);
for(int T=1;T<=t;T++){
solve(T);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 35060kb
input:
4 1 1 1 1
output:
No No No No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'