답안 #38790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38790 2018-01-06T14:56:43 Z DenXman111 Bootfall (IZhO17_bootfall) C++14
13 / 100
83 ms 6088 KB
#include <iostream>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))

#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0)
#define endl '\n'

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=250000;

using namespace std;

int dp[MAXN + 502], new_dp[MAXN + 502], a[MAXN];
int can[MAXN + 502];
vector <int> ans;

int main()
{
    fast_io;

    int n, sum = 0;

    cin >> n;
    for (int i = 1; i <= n; ++i) {cin >> a[i]; sum += a[i];}
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = MAXN; j >= a[i]; --j) dp[j] += dp[j - a[i]];
    }
       if (sum % 2 || !dp[sum / 2]) return cout << 0, 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= MAXN; ++j) new_dp[j] += dp[j], new_dp[j + a[i]] -= new_dp[j];
        int new_sum = sum + a[i];
        for (int j = 0; j <= MAXN; ++j)
            if (sum - a[i] - j >= 0) if ((new_sum + j) % 2 == 0 && new_dp[(sum - a[i] - j) / 2]) ++can[j];
    }
    for (int i = 1; i <= MAXN; ++i) if (can[i] == n) ans.push_back(i);
    cout << ans.size() << endl; for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:54:51: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     cout << ans.size() << endl; for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
                                                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
10 Correct 26 ms 6088 KB Output is correct
11 Correct 36 ms 6088 KB Output is correct
12 Correct 33 ms 6088 KB Output is correct
13 Correct 19 ms 6088 KB Output is correct
14 Correct 26 ms 6088 KB Output is correct
15 Correct 26 ms 6088 KB Output is correct
16 Correct 26 ms 6088 KB Output is correct
17 Correct 13 ms 6088 KB Output is correct
18 Correct 23 ms 6088 KB Output is correct
19 Correct 23 ms 6088 KB Output is correct
20 Correct 26 ms 6088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
10 Correct 26 ms 6088 KB Output is correct
11 Correct 36 ms 6088 KB Output is correct
12 Correct 33 ms 6088 KB Output is correct
13 Correct 19 ms 6088 KB Output is correct
14 Correct 26 ms 6088 KB Output is correct
15 Correct 26 ms 6088 KB Output is correct
16 Correct 26 ms 6088 KB Output is correct
17 Correct 13 ms 6088 KB Output is correct
18 Correct 23 ms 6088 KB Output is correct
19 Correct 23 ms 6088 KB Output is correct
20 Correct 26 ms 6088 KB Output is correct
21 Correct 53 ms 6088 KB Output is correct
22 Correct 69 ms 6088 KB Output is correct
23 Correct 39 ms 6088 KB Output is correct
24 Runtime error 83 ms 6088 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
10 Correct 26 ms 6088 KB Output is correct
11 Correct 36 ms 6088 KB Output is correct
12 Correct 33 ms 6088 KB Output is correct
13 Correct 19 ms 6088 KB Output is correct
14 Correct 26 ms 6088 KB Output is correct
15 Correct 26 ms 6088 KB Output is correct
16 Correct 26 ms 6088 KB Output is correct
17 Correct 13 ms 6088 KB Output is correct
18 Correct 23 ms 6088 KB Output is correct
19 Correct 23 ms 6088 KB Output is correct
20 Correct 26 ms 6088 KB Output is correct
21 Correct 53 ms 6088 KB Output is correct
22 Correct 69 ms 6088 KB Output is correct
23 Correct 39 ms 6088 KB Output is correct
24 Runtime error 83 ms 6088 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
10 Correct 26 ms 6088 KB Output is correct
11 Correct 36 ms 6088 KB Output is correct
12 Correct 33 ms 6088 KB Output is correct
13 Correct 19 ms 6088 KB Output is correct
14 Correct 26 ms 6088 KB Output is correct
15 Correct 26 ms 6088 KB Output is correct
16 Correct 26 ms 6088 KB Output is correct
17 Correct 13 ms 6088 KB Output is correct
18 Correct 23 ms 6088 KB Output is correct
19 Correct 23 ms 6088 KB Output is correct
20 Correct 26 ms 6088 KB Output is correct
21 Correct 53 ms 6088 KB Output is correct
22 Correct 69 ms 6088 KB Output is correct
23 Correct 39 ms 6088 KB Output is correct
24 Runtime error 83 ms 6088 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6088 KB Output is correct
2 Correct 9 ms 6088 KB Output is correct
3 Correct 3 ms 6088 KB Output is correct
4 Correct 6 ms 6088 KB Output is correct
5 Correct 16 ms 6088 KB Output is correct
6 Correct 9 ms 6088 KB Output is correct
7 Correct 9 ms 6088 KB Output is correct
8 Correct 9 ms 6088 KB Output is correct
9 Correct 9 ms 6088 KB Output is correct
10 Correct 26 ms 6088 KB Output is correct
11 Correct 36 ms 6088 KB Output is correct
12 Correct 33 ms 6088 KB Output is correct
13 Correct 19 ms 6088 KB Output is correct
14 Correct 26 ms 6088 KB Output is correct
15 Correct 26 ms 6088 KB Output is correct
16 Correct 26 ms 6088 KB Output is correct
17 Correct 13 ms 6088 KB Output is correct
18 Correct 23 ms 6088 KB Output is correct
19 Correct 23 ms 6088 KB Output is correct
20 Correct 26 ms 6088 KB Output is correct
21 Correct 53 ms 6088 KB Output is correct
22 Correct 69 ms 6088 KB Output is correct
23 Correct 39 ms 6088 KB Output is correct
24 Runtime error 83 ms 6088 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -