QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#76520 | #5475. Make a Loop | XKError | WA | 2ms | 5492kb | C++ | 768b | 2023-02-10 10:49:20 | 2023-02-10 10:49:21 |
Judging History
answer
#include <bits/stdc++.h>
#define maxn 105
#define maxm maxn * 10005
//#define maxm 10
using namespace std;
int n;
int f[2][maxm];
int g[2][maxm];
void $(int &a, int b) {
a = min(2, a + b);
}
int main() {
scanf("%d", &n);
int m = 0;
f[0][0] = 1;
for (int i = 1; i <= n; i++) {
int r;
scanf("%d", &r);
m += r;
for (int j = 0; j <= m; j++) {
if (j >= r) $(g[0][j], f[1][j - r]);
if (j + r <= m) $(g[0][j], f[0][j + r]);
if (j >= r) $(g[1][j], f[0][j - r]);
if (j + r <= m) $(g[1][j], f[1][j + r]);
}
for (int j = 0; j <= m; j++) {
f[0][j] = g[0][j];
f[1][j] = g[1][j];
g[0][j] = g[1][j] = 0;
// cout<<f[0][j]<<" "
}
}
if (f[0][0] == 2) puts("Yes");
else puts("No");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5424kb
input:
4 1 1 1 1
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 5492kb
input:
6 1 3 1 3 1 3
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'