답안 #497640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497640 2021-12-23T12:31:44 Z khangal Bootfall (IZhO17_bootfall) C++14
100 / 100
382 ms 12832 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18 
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
//ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//vector<ll> edge[1234567];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
    ll res = 1;
    while (val) {
        if (val % 2 == 1) {
            res = res * base;
        }
        base = base * base;
        base %= mod;
        res %= mod;
        val /= 2;
    }
    return res;
}
bool comp(pl x,pl y){
    if(x.ff>y.ff)return true;
    return false;
}
ll find(ll x){
    if(x==par[x])return x;
    else return par[x]=find(par[x]);
}
class A {
public:
    static void funcA() {
        cin>>n;
        ll dp[1234567];
        dp[0]=1;
        for(int i=1;i<=n;i++){
            cin>>arr[i];
            sum+=arr[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=sum;j>=0;j--){
                if(j-arr[i]>=0){
                    dp[j] += dp[j-arr[i]];
                }
            }
        }
        bool ok[1234567]={0};
        for(int i=1;i<=n;i++){
            for(int j=arr[i];j<=sum;j++){
                dp[j] -= dp[j-arr[i]];
            }
            for(int j=1;j<=sum;j++){
                ll k = sum - arr[i] + j;
                if(k%2==1 || dp[k/2]==0){
                    ok[j]=1;
                }
            }
            for(int j=sum;j>=arr[i];j--){
                dp[j] += dp[j-arr[i]];
            }
        }
        vl vec;
        for(int i=1;i<=sum;i++){
            if(ok[i]==0)vec.pb(i);
        }
        if(sum%2==1 || dp[sum/2]==0)vec.clear();
        cout<<vec.size()<<'\n';
        for(auto u:vec){
            cout<<u<<' ';
        }
    }
}lol;
void solve() {
    A::funcA();
}
int main() {
    ll T = 1;
    //cin>>T;
    boost;
    while (T--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
10 Correct 5 ms 11084 KB Output is correct
11 Correct 5 ms 11084 KB Output is correct
12 Correct 6 ms 11084 KB Output is correct
13 Correct 4 ms 11084 KB Output is correct
14 Correct 5 ms 11084 KB Output is correct
15 Correct 6 ms 11084 KB Output is correct
16 Correct 5 ms 11084 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 5 ms 11084 KB Output is correct
19 Correct 5 ms 11084 KB Output is correct
20 Correct 5 ms 11084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
10 Correct 5 ms 11084 KB Output is correct
11 Correct 5 ms 11084 KB Output is correct
12 Correct 6 ms 11084 KB Output is correct
13 Correct 4 ms 11084 KB Output is correct
14 Correct 5 ms 11084 KB Output is correct
15 Correct 6 ms 11084 KB Output is correct
16 Correct 5 ms 11084 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 5 ms 11084 KB Output is correct
19 Correct 5 ms 11084 KB Output is correct
20 Correct 5 ms 11084 KB Output is correct
21 Correct 6 ms 11212 KB Output is correct
22 Correct 6 ms 11172 KB Output is correct
23 Correct 6 ms 11212 KB Output is correct
24 Correct 6 ms 11212 KB Output is correct
25 Correct 8 ms 11212 KB Output is correct
26 Correct 8 ms 11176 KB Output is correct
27 Correct 8 ms 11212 KB Output is correct
28 Correct 8 ms 11212 KB Output is correct
29 Correct 8 ms 11084 KB Output is correct
30 Correct 7 ms 11084 KB Output is correct
31 Correct 7 ms 11180 KB Output is correct
32 Correct 8 ms 11184 KB Output is correct
33 Correct 9 ms 11084 KB Output is correct
34 Correct 8 ms 11084 KB Output is correct
35 Correct 8 ms 11084 KB Output is correct
36 Correct 6 ms 11212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
10 Correct 5 ms 11084 KB Output is correct
11 Correct 5 ms 11084 KB Output is correct
12 Correct 6 ms 11084 KB Output is correct
13 Correct 4 ms 11084 KB Output is correct
14 Correct 5 ms 11084 KB Output is correct
15 Correct 6 ms 11084 KB Output is correct
16 Correct 5 ms 11084 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 5 ms 11084 KB Output is correct
19 Correct 5 ms 11084 KB Output is correct
20 Correct 5 ms 11084 KB Output is correct
21 Correct 6 ms 11212 KB Output is correct
22 Correct 6 ms 11172 KB Output is correct
23 Correct 6 ms 11212 KB Output is correct
24 Correct 6 ms 11212 KB Output is correct
25 Correct 8 ms 11212 KB Output is correct
26 Correct 8 ms 11176 KB Output is correct
27 Correct 8 ms 11212 KB Output is correct
28 Correct 8 ms 11212 KB Output is correct
29 Correct 8 ms 11084 KB Output is correct
30 Correct 7 ms 11084 KB Output is correct
31 Correct 7 ms 11180 KB Output is correct
32 Correct 8 ms 11184 KB Output is correct
33 Correct 9 ms 11084 KB Output is correct
34 Correct 8 ms 11084 KB Output is correct
35 Correct 8 ms 11084 KB Output is correct
36 Correct 6 ms 11212 KB Output is correct
37 Correct 17 ms 11424 KB Output is correct
38 Correct 17 ms 11428 KB Output is correct
39 Correct 51 ms 11084 KB Output is correct
40 Correct 45 ms 11444 KB Output is correct
41 Correct 64 ms 11160 KB Output is correct
42 Correct 30 ms 11460 KB Output is correct
43 Correct 47 ms 11552 KB Output is correct
44 Correct 48 ms 11540 KB Output is correct
45 Correct 61 ms 11548 KB Output is correct
46 Correct 32 ms 11160 KB Output is correct
47 Correct 31 ms 11432 KB Output is correct
48 Correct 51 ms 11556 KB Output is correct
49 Correct 49 ms 11204 KB Output is correct
50 Correct 33 ms 11424 KB Output is correct
51 Correct 36 ms 11084 KB Output is correct
52 Correct 63 ms 11676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
10 Correct 5 ms 11084 KB Output is correct
11 Correct 5 ms 11084 KB Output is correct
12 Correct 6 ms 11084 KB Output is correct
13 Correct 4 ms 11084 KB Output is correct
14 Correct 5 ms 11084 KB Output is correct
15 Correct 6 ms 11084 KB Output is correct
16 Correct 5 ms 11084 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 5 ms 11084 KB Output is correct
19 Correct 5 ms 11084 KB Output is correct
20 Correct 5 ms 11084 KB Output is correct
21 Correct 6 ms 11212 KB Output is correct
22 Correct 6 ms 11172 KB Output is correct
23 Correct 6 ms 11212 KB Output is correct
24 Correct 6 ms 11212 KB Output is correct
25 Correct 8 ms 11212 KB Output is correct
26 Correct 8 ms 11176 KB Output is correct
27 Correct 8 ms 11212 KB Output is correct
28 Correct 8 ms 11212 KB Output is correct
29 Correct 8 ms 11084 KB Output is correct
30 Correct 7 ms 11084 KB Output is correct
31 Correct 7 ms 11180 KB Output is correct
32 Correct 8 ms 11184 KB Output is correct
33 Correct 9 ms 11084 KB Output is correct
34 Correct 8 ms 11084 KB Output is correct
35 Correct 8 ms 11084 KB Output is correct
36 Correct 6 ms 11212 KB Output is correct
37 Correct 17 ms 11424 KB Output is correct
38 Correct 17 ms 11428 KB Output is correct
39 Correct 51 ms 11084 KB Output is correct
40 Correct 45 ms 11444 KB Output is correct
41 Correct 64 ms 11160 KB Output is correct
42 Correct 30 ms 11460 KB Output is correct
43 Correct 47 ms 11552 KB Output is correct
44 Correct 48 ms 11540 KB Output is correct
45 Correct 61 ms 11548 KB Output is correct
46 Correct 32 ms 11160 KB Output is correct
47 Correct 31 ms 11432 KB Output is correct
48 Correct 51 ms 11556 KB Output is correct
49 Correct 49 ms 11204 KB Output is correct
50 Correct 33 ms 11424 KB Output is correct
51 Correct 36 ms 11084 KB Output is correct
52 Correct 63 ms 11676 KB Output is correct
53 Correct 48 ms 11544 KB Output is correct
54 Correct 63 ms 11584 KB Output is correct
55 Correct 126 ms 11928 KB Output is correct
56 Correct 59 ms 11584 KB Output is correct
57 Correct 135 ms 11964 KB Output is correct
58 Correct 83 ms 11660 KB Output is correct
59 Correct 84 ms 11792 KB Output is correct
60 Correct 78 ms 11156 KB Output is correct
61 Correct 96 ms 11796 KB Output is correct
62 Correct 95 ms 11912 KB Output is correct
63 Correct 125 ms 11836 KB Output is correct
64 Correct 105 ms 11920 KB Output is correct
65 Correct 57 ms 11156 KB Output is correct
66 Correct 53 ms 11292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11140 KB Output is correct
2 Correct 5 ms 11084 KB Output is correct
3 Correct 6 ms 11084 KB Output is correct
4 Correct 6 ms 11064 KB Output is correct
5 Correct 4 ms 11084 KB Output is correct
6 Correct 4 ms 11084 KB Output is correct
7 Correct 4 ms 11084 KB Output is correct
8 Correct 5 ms 11084 KB Output is correct
9 Correct 4 ms 11084 KB Output is correct
10 Correct 5 ms 11084 KB Output is correct
11 Correct 5 ms 11084 KB Output is correct
12 Correct 6 ms 11084 KB Output is correct
13 Correct 4 ms 11084 KB Output is correct
14 Correct 5 ms 11084 KB Output is correct
15 Correct 6 ms 11084 KB Output is correct
16 Correct 5 ms 11084 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 5 ms 11084 KB Output is correct
19 Correct 5 ms 11084 KB Output is correct
20 Correct 5 ms 11084 KB Output is correct
21 Correct 6 ms 11212 KB Output is correct
22 Correct 6 ms 11172 KB Output is correct
23 Correct 6 ms 11212 KB Output is correct
24 Correct 6 ms 11212 KB Output is correct
25 Correct 8 ms 11212 KB Output is correct
26 Correct 8 ms 11176 KB Output is correct
27 Correct 8 ms 11212 KB Output is correct
28 Correct 8 ms 11212 KB Output is correct
29 Correct 8 ms 11084 KB Output is correct
30 Correct 7 ms 11084 KB Output is correct
31 Correct 7 ms 11180 KB Output is correct
32 Correct 8 ms 11184 KB Output is correct
33 Correct 9 ms 11084 KB Output is correct
34 Correct 8 ms 11084 KB Output is correct
35 Correct 8 ms 11084 KB Output is correct
36 Correct 6 ms 11212 KB Output is correct
37 Correct 17 ms 11424 KB Output is correct
38 Correct 17 ms 11428 KB Output is correct
39 Correct 51 ms 11084 KB Output is correct
40 Correct 45 ms 11444 KB Output is correct
41 Correct 64 ms 11160 KB Output is correct
42 Correct 30 ms 11460 KB Output is correct
43 Correct 47 ms 11552 KB Output is correct
44 Correct 48 ms 11540 KB Output is correct
45 Correct 61 ms 11548 KB Output is correct
46 Correct 32 ms 11160 KB Output is correct
47 Correct 31 ms 11432 KB Output is correct
48 Correct 51 ms 11556 KB Output is correct
49 Correct 49 ms 11204 KB Output is correct
50 Correct 33 ms 11424 KB Output is correct
51 Correct 36 ms 11084 KB Output is correct
52 Correct 63 ms 11676 KB Output is correct
53 Correct 48 ms 11544 KB Output is correct
54 Correct 63 ms 11584 KB Output is correct
55 Correct 126 ms 11928 KB Output is correct
56 Correct 59 ms 11584 KB Output is correct
57 Correct 135 ms 11964 KB Output is correct
58 Correct 83 ms 11660 KB Output is correct
59 Correct 84 ms 11792 KB Output is correct
60 Correct 78 ms 11156 KB Output is correct
61 Correct 96 ms 11796 KB Output is correct
62 Correct 95 ms 11912 KB Output is correct
63 Correct 125 ms 11836 KB Output is correct
64 Correct 105 ms 11920 KB Output is correct
65 Correct 57 ms 11156 KB Output is correct
66 Correct 53 ms 11292 KB Output is correct
67 Correct 99 ms 11792 KB Output is correct
68 Correct 190 ms 11160 KB Output is correct
69 Correct 331 ms 12668 KB Output is correct
70 Correct 206 ms 12200 KB Output is correct
71 Correct 211 ms 12056 KB Output is correct
72 Correct 201 ms 11172 KB Output is correct
73 Correct 188 ms 11168 KB Output is correct
74 Correct 342 ms 12824 KB Output is correct
75 Correct 277 ms 12432 KB Output is correct
76 Correct 358 ms 12688 KB Output is correct
77 Correct 382 ms 12832 KB Output is correct