# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
229857 | pedroslrey | Bootfall (IZhO17_bootfall) | C++14 | 182 ms | 9216 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Bootfall subtask 1
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using lli = long long int;
#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define fi first
#define se second
#define all(xs) xs.begin(), xs.end()
const int INF = 1e9;
int xs[110];
int dp[110][10010];
int marc[10010];
void make_dp(int n, int s, int ignore) {
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int x = 0; x <= s; ++x) {
if (i == ignore) {
dp[i][x] = dp[i-1][x];
continue;
}
int k = 0;
if (x - xs[i] >= 0) k = dp[i-1][x - xs[i]];
dp[i][x] = dp[i-1][x] || k;
}
}
}
void solve(int n) {
int s = 0;
for (int i = 1; i <= n; ++i)
s += xs[i];
make_dp(n, s, 0);
if (!dp[n][s/2] || s%2 == 1) {
printf("0\n");
return;
}
for (int i = 1; i <= n; ++i) {
make_dp(n, s, i);
for (int k = 1; k <= s; ++k) {
if ((s - xs[i] + k)%2 == 1) marc[k] = 0;
if (dp[n][((s - xs[i] + k)/2 - k)]) ++marc[k];
}
}
vector<int> ans;
for (int k = 1; k <= s; ++k)
if (marc[k] == n) ans.pb(k);
printf("%d\n", (int) ans.size());
for (int a: ans)
printf("%d ", a);
printf("\n");
}
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
scanf("%d", &xs[i]);
solve(n);
}
컴파일 시 표준 에러 (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... |