답안 #331658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331658 2020-11-29T12:10:39 Z vitkishloh228 Bootfall (IZhO17_bootfall) C++14
13 / 100
972 ms 512 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
const int maxc = 10000;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int S = 0;
    for (auto elem : a) {
        S += elem;
    }
    bitset<maxc> dp1;
    dp1[0] = 1;
    for (int i = 0; i < n; i++) {
        dp1 |= dp1 << a[i];
    }
    vector<int> ans;
    for (int L = 0; L < 1000; ++L) {
        int needsum = (S + L);
        //if ((S + L) % 2 == 1) continue;
        bool ok = dp1[S / 2];
        //cout << ok << endl;
        for (int j = 0; j < n; ++j) {
            if ((S + L - a[j]) % 2 == 1) {
                ok = false;
                break;
            }
            bitset<maxc> dp;
            dp[0] = 1;
            for (int i = 0; i < n; i++) {
                if (i == j) continue;
                dp |= dp << a[i];
            }
            dp |= dp << L;
            if (!dp[(S + L - a[j]) / 2]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans.push_back(L);
        }
    }
    cout << ans.size() << '\n';
    for (auto elem : ans) cout << elem << ' ';
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:23:13: warning: unused variable 'needsum' [-Wunused-variable]
   23 |         int needsum = (S + L);
      |             ^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 13 ms 364 KB Output is correct
11 Correct 55 ms 364 KB Output is correct
12 Correct 9 ms 364 KB Output is correct
13 Correct 8 ms 364 KB Output is correct
14 Correct 64 ms 512 KB Output is correct
15 Correct 43 ms 364 KB Output is correct
16 Correct 55 ms 364 KB Output is correct
17 Correct 16 ms 364 KB Output is correct
18 Correct 35 ms 364 KB Output is correct
19 Correct 33 ms 364 KB Output is correct
20 Correct 14 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 13 ms 364 KB Output is correct
11 Correct 55 ms 364 KB Output is correct
12 Correct 9 ms 364 KB Output is correct
13 Correct 8 ms 364 KB Output is correct
14 Correct 64 ms 512 KB Output is correct
15 Correct 43 ms 364 KB Output is correct
16 Correct 55 ms 364 KB Output is correct
17 Correct 16 ms 364 KB Output is correct
18 Correct 35 ms 364 KB Output is correct
19 Correct 33 ms 364 KB Output is correct
20 Correct 14 ms 364 KB Output is correct
21 Incorrect 972 ms 368 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 13 ms 364 KB Output is correct
11 Correct 55 ms 364 KB Output is correct
12 Correct 9 ms 364 KB Output is correct
13 Correct 8 ms 364 KB Output is correct
14 Correct 64 ms 512 KB Output is correct
15 Correct 43 ms 364 KB Output is correct
16 Correct 55 ms 364 KB Output is correct
17 Correct 16 ms 364 KB Output is correct
18 Correct 35 ms 364 KB Output is correct
19 Correct 33 ms 364 KB Output is correct
20 Correct 14 ms 364 KB Output is correct
21 Incorrect 972 ms 368 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 13 ms 364 KB Output is correct
11 Correct 55 ms 364 KB Output is correct
12 Correct 9 ms 364 KB Output is correct
13 Correct 8 ms 364 KB Output is correct
14 Correct 64 ms 512 KB Output is correct
15 Correct 43 ms 364 KB Output is correct
16 Correct 55 ms 364 KB Output is correct
17 Correct 16 ms 364 KB Output is correct
18 Correct 35 ms 364 KB Output is correct
19 Correct 33 ms 364 KB Output is correct
20 Correct 14 ms 364 KB Output is correct
21 Incorrect 972 ms 368 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 14 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 15 ms 364 KB Output is correct
9 Correct 3 ms 364 KB Output is correct
10 Correct 13 ms 364 KB Output is correct
11 Correct 55 ms 364 KB Output is correct
12 Correct 9 ms 364 KB Output is correct
13 Correct 8 ms 364 KB Output is correct
14 Correct 64 ms 512 KB Output is correct
15 Correct 43 ms 364 KB Output is correct
16 Correct 55 ms 364 KB Output is correct
17 Correct 16 ms 364 KB Output is correct
18 Correct 35 ms 364 KB Output is correct
19 Correct 33 ms 364 KB Output is correct
20 Correct 14 ms 364 KB Output is correct
21 Incorrect 972 ms 368 KB Output isn't correct
22 Halted 0 ms 0 KB -