QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744701 | #5475. Make a Loop | minggg | WA | 1ms | 3800kb | C++14 | 1.3kb | 2024-11-13 22:54:55 | 2024-11-13 22:55:03 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int MOD = 1e9 + 7;
const int inf = 2e18;
const int N = 105;
const int M = 1e6 + 7;
int n, a[N], s, f[M][2][2];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i], s += a[i];
if(s % 2 != 0 or n % 2 != 0) {
cout << "NO";
return 0;
}
s /= 2;
f[0][0][0] = 1;
for(int k = 1; k <= n; k++) {
int id = k % 2;
for(int i = 0; i <= s; i++) {
for(int j = 0; j < 2; j++) {
f[i][id][j] = f[i][id ^ 1][j];
if(f[i][id][j] > 4) f[i][id][j] = 4;
}
if(i >= a[k]) {
for(int j = 0; j < 2; j++) {
f[i][id][j] += f[i - a[k]][id ^ 1][j ^ 1];
if(f[i][id][j] > 4) f[i][id][j] = 4;
}
}
// cout << i << ' ' << k << ' ' << f[i][id][1] << ' ' << f[i][id][0] << ln;
}
}
if(f[s][0][n % 2] >= 4) cout << "YES";
else cout << "NO";
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3800kb
input:
4 1 1 1 1
output:
YES
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'YES'