QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#185955 | #5475. Make a Loop | luanmenglei | WA | 13ms | 19088kb | C++17 | 777b | 2023-09-22 21:35:14 | 2023-09-22 21:35:15 |
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] < 2) {
cout << "No\n";
} else {
cout << "Yes\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 9ms
memory: 19008kb
input:
4 1 1 1 1
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 13ms
memory: 19052kb
input:
6 1 3 1 3 1 3
output:
Yes
result:
ok single line: 'Yes'
Test #3:
score: -100
Wrong Answer
time: 12ms
memory: 19088kb
input:
6 2 2 1 1 1 1
output:
Yes
result:
wrong answer 1st lines differ - expected: 'No', found: 'Yes'