QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185963 | #5475. Make a Loop | luanmenglei | WA | 6ms | 19260kb | C++17 | 777b | 2023-09-22 21:42:16 | 2023-09-22 21:42:17 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
using namespace std;
const int N = 1000005;
int f[2][N], g[2][N];
void add(int &x, int y) { x = min(3, x + y); }
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n; cin >> n;
int sum = 0;
f[0][0] = 1;
rep(i, 0, n - 1) {
int x; cin >> x;
memcpy(g, f, sizeof g);
rep(o, 0, 1) {
rep(s, 0, sum) {
add(g[!o][s + x], f[o][s]);
}
}
sum += x;
memcpy(f, g, sizeof f);
}
if (sum % 2 || f[0][sum / 2] < 4) {
cout << "No\n";
} else {
cout << "Yes\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 19260kb
input:
4 1 1 1 1
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'