QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#301676 | #5475. Make a Loop | AlphaMale06 | WA | 0ms | 3564kb | C++20 | 1.1kb | 2024-01-10 04:54:22 | 2024-01-10 04:54:22 |
Judging History
answer
#include <bits/stdc++.h>
/*
Oce nas,
koji si na nebesima,
da se sveti ime Tvoje,
da dodje carstvo Tvoje,
da bude volja Tvoja,
i na zemlji, kao i na nebu.
Hleb nas nasusni daj nam danas,
i oprosti nam dugove nase,
kao sto i mi oprastamo duznicima svojim,
i ne uvedi nas u iskusenje,
no izbavi nas od zloga.
Jer je Tvoje Carstvo,
i sila, i slava,
u vekove vekova.
Amin.
*/
using namespace std;
short dp[2][500001];
short a[101];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int a[n];
int sum=0;
for(int i=0; i< n; ++i){
cin >> a[i];
sum+=a[i];
}
if(n&1 || sum&1){
cout << "No\n";
return 0;
}
sort(a, a+n);
dp[0][0]=1;
int mxsum=sum>>1;
sum=0;
for(int i=0; i< n; ++i){
sum+=a[i];
int to=min(mxsum, sum);
for(int j=to; j>=a[i]; --j){
int danic = dp[1][j-a[i]]+dp[0][j];
int picka = dp[0][j-a[i]]+dp[1][j];
dp[0][j]=danic;
dp[1][j]=picka;
}
if(dp[0][mxsum/2]>=4){
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
4 1 1 1 1
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'