# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1099935 | nnqw | Bootfall (IZhO17_bootfall) | C++17 | 0 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const int N = 505;
int a[N];
int main() {
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
int totalSum = accumulate(a + 1, a + n + 1, 0);
vector<int> A;
for(int x = 0; x <= totalSum; ++x) {
a[n + 1] = x; // Include Tima's strength
int currentSum = totalSum + x;
// If the total sum is odd, skip to the next x
if (currentSum % 2 != 0) continue;
int half = currentSum / 2;
vector<bool> dp(half + 1, false);
dp[0] = true;
// Fill the DP table
for(int i = 1; i <= n + 1; ++i) {
int strength = a[i];
for(int j = half; j >= strength; --j) {
dp[j] = dp[j] || dp[j - strength];
}
}
// Check if we can achieve the half-sum
if (dp[half]) {
A.push_back(x);
}
}
printf("%d\n", (int)A.size());
for(int i : A)
printf("%d ", i);
puts("");
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... |