# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566222 | 1zaid1 | Bootfall (IZhO17_bootfall) | C++17 | 2 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
#define int long long
#pragma GCC diagnostic ignored "-Wunused-result"
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(15);
if (name.size()) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
const int M = 5e2+5, MOD = 1e6+7;
bool can[M][M];
int a[M];
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
srand(time(0));
// setIO("citystate");
int n;
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
n++;
vector<int> ans;
for (int k = 1; k <= 1000; k++) {
a[n] = k;
sum += a[n];
int ok = 1;
for (int r = 1; r <= n; r++) {
if ((sum-a[r])%2) {
ok = false;
break;
}
int tmp = 0;
sum -= a[r];
swap(a[r], tmp);
for (int i = 0; i <= n; i++) can[i][0] = 1;
for (int x = 0; x <= sum/2; x++) {
for (int i = 1; i <= n; i++) {
can[i][x] = can[i-1][x];
if (x >= a[i]) can[i][x] |= can[i-1][x-a[i]];
}
}
swap(a[r], tmp);
sum += a[r];
if (!can[n][(sum-a[r])/2]) {
ok = false;
break;
}
for (int x = 0; x <= sum/2; x++) for (int i = 0; i <= n; i++) can[i][x] = 0;
}
if (ok) ans.push_back(k);
sum -= a[n];
}
cout << ans.size() << endl;
for (int i:ans) cout << i << ' '; cout << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |