답안 #678385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
678385 2023-01-05T17:32:42 Z Ahmed57 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 5540 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

using namespace std;
long long dp[2*500*500+1];
long long mod = int(1e9+7);
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int arr[n] , sum = 0;
    for(int i = 0;i<n;i++){
        cin>>arr[i];sum+=arr[i];
    }
    dp[0] = 1;
    for(int i = 0;i<n;i++){
        for(int j = 2*sum;j>=arr[i];j--){
            dp[j]+=dp[j-arr[i]];
            if(dp[j]>=1e18)dp[j]%=mod;
        }
    }
    if(sum%2||(!dp[sum/2])){
        cout<<"0";
        return 0;
    }
    vector<int> v;
    for(int i = 1;i<=sum;i++){v.push_back(i);}
    for(int it = 0;it<n;it++){
        for(int j = arr[it];j<=2*sum;j++){
            dp[j]-=dp[j-arr[it]];
            dp[j]%=mod;
            if(dp[j]<0){dp[j]+=mod;dp[j]%=mod;}
        }
        vector<int> c;
        for(auto j:v){
            if((sum-arr[it]+j)%2){
                continue;
            }
            int ne = sum-arr[it]+j;
            int d = (dp[ne/2]>0);
            if(j<=ne/2)d|=(dp[(ne/2)-j]>0);
            if(d==1)c.push_back(j);
        }v = c;
        for(int j = 2*sum;j>=arr[it];j--){
            dp[j]+=dp[j-arr[it]];
            if(dp[j]>=1e18)dp[j]%=mod;
        }
    }
    cout<<v.size()<<"\n";
    for(auto i:v)cout<<i<<" ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 456 KB Output is correct
25 Correct 13 ms 468 KB Output is correct
26 Correct 16 ms 468 KB Output is correct
27 Correct 16 ms 564 KB Output is correct
28 Correct 16 ms 576 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 10 ms 464 KB Output is correct
31 Correct 13 ms 468 KB Output is correct
32 Correct 9 ms 468 KB Output is correct
33 Correct 15 ms 592 KB Output is correct
34 Correct 14 ms 596 KB Output is correct
35 Correct 14 ms 468 KB Output is correct
36 Correct 8 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 456 KB Output is correct
25 Correct 13 ms 468 KB Output is correct
26 Correct 16 ms 468 KB Output is correct
27 Correct 16 ms 564 KB Output is correct
28 Correct 16 ms 576 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 10 ms 464 KB Output is correct
31 Correct 13 ms 468 KB Output is correct
32 Correct 9 ms 468 KB Output is correct
33 Correct 15 ms 592 KB Output is correct
34 Correct 14 ms 596 KB Output is correct
35 Correct 14 ms 468 KB Output is correct
36 Correct 8 ms 452 KB Output is correct
37 Correct 70 ms 844 KB Output is correct
38 Correct 78 ms 852 KB Output is correct
39 Correct 205 ms 1660 KB Output is correct
40 Correct 161 ms 1076 KB Output is correct
41 Correct 268 ms 2000 KB Output is correct
42 Correct 138 ms 1028 KB Output is correct
43 Correct 246 ms 1944 KB Output is correct
44 Correct 261 ms 1676 KB Output is correct
45 Correct 250 ms 1680 KB Output is correct
46 Correct 129 ms 1056 KB Output is correct
47 Correct 158 ms 1076 KB Output is correct
48 Correct 243 ms 1944 KB Output is correct
49 Correct 223 ms 1676 KB Output is correct
50 Correct 148 ms 1080 KB Output is correct
51 Correct 26 ms 724 KB Output is correct
52 Correct 320 ms 2060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 456 KB Output is correct
25 Correct 13 ms 468 KB Output is correct
26 Correct 16 ms 468 KB Output is correct
27 Correct 16 ms 564 KB Output is correct
28 Correct 16 ms 576 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 10 ms 464 KB Output is correct
31 Correct 13 ms 468 KB Output is correct
32 Correct 9 ms 468 KB Output is correct
33 Correct 15 ms 592 KB Output is correct
34 Correct 14 ms 596 KB Output is correct
35 Correct 14 ms 468 KB Output is correct
36 Correct 8 ms 452 KB Output is correct
37 Correct 70 ms 844 KB Output is correct
38 Correct 78 ms 852 KB Output is correct
39 Correct 205 ms 1660 KB Output is correct
40 Correct 161 ms 1076 KB Output is correct
41 Correct 268 ms 2000 KB Output is correct
42 Correct 138 ms 1028 KB Output is correct
43 Correct 246 ms 1944 KB Output is correct
44 Correct 261 ms 1676 KB Output is correct
45 Correct 250 ms 1680 KB Output is correct
46 Correct 129 ms 1056 KB Output is correct
47 Correct 158 ms 1076 KB Output is correct
48 Correct 243 ms 1944 KB Output is correct
49 Correct 223 ms 1676 KB Output is correct
50 Correct 148 ms 1080 KB Output is correct
51 Correct 26 ms 724 KB Output is correct
52 Correct 320 ms 2060 KB Output is correct
53 Correct 252 ms 1560 KB Output is correct
54 Correct 359 ms 1724 KB Output is correct
55 Correct 703 ms 3092 KB Output is correct
56 Correct 325 ms 1652 KB Output is correct
57 Correct 767 ms 3096 KB Output is correct
58 Correct 398 ms 1876 KB Output is correct
59 Correct 511 ms 2224 KB Output is correct
60 Correct 74 ms 1276 KB Output is correct
61 Correct 576 ms 2540 KB Output is correct
62 Correct 573 ms 2740 KB Output is correct
63 Correct 626 ms 2864 KB Output is correct
64 Correct 592 ms 2764 KB Output is correct
65 Correct 199 ms 1460 KB Output is correct
66 Correct 234 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 8 ms 456 KB Output is correct
25 Correct 13 ms 468 KB Output is correct
26 Correct 16 ms 468 KB Output is correct
27 Correct 16 ms 564 KB Output is correct
28 Correct 16 ms 576 KB Output is correct
29 Correct 16 ms 468 KB Output is correct
30 Correct 10 ms 464 KB Output is correct
31 Correct 13 ms 468 KB Output is correct
32 Correct 9 ms 468 KB Output is correct
33 Correct 15 ms 592 KB Output is correct
34 Correct 14 ms 596 KB Output is correct
35 Correct 14 ms 468 KB Output is correct
36 Correct 8 ms 452 KB Output is correct
37 Correct 70 ms 844 KB Output is correct
38 Correct 78 ms 852 KB Output is correct
39 Correct 205 ms 1660 KB Output is correct
40 Correct 161 ms 1076 KB Output is correct
41 Correct 268 ms 2000 KB Output is correct
42 Correct 138 ms 1028 KB Output is correct
43 Correct 246 ms 1944 KB Output is correct
44 Correct 261 ms 1676 KB Output is correct
45 Correct 250 ms 1680 KB Output is correct
46 Correct 129 ms 1056 KB Output is correct
47 Correct 158 ms 1076 KB Output is correct
48 Correct 243 ms 1944 KB Output is correct
49 Correct 223 ms 1676 KB Output is correct
50 Correct 148 ms 1080 KB Output is correct
51 Correct 26 ms 724 KB Output is correct
52 Correct 320 ms 2060 KB Output is correct
53 Correct 252 ms 1560 KB Output is correct
54 Correct 359 ms 1724 KB Output is correct
55 Correct 703 ms 3092 KB Output is correct
56 Correct 325 ms 1652 KB Output is correct
57 Correct 767 ms 3096 KB Output is correct
58 Correct 398 ms 1876 KB Output is correct
59 Correct 511 ms 2224 KB Output is correct
60 Correct 74 ms 1276 KB Output is correct
61 Correct 576 ms 2540 KB Output is correct
62 Correct 573 ms 2740 KB Output is correct
63 Correct 626 ms 2864 KB Output is correct
64 Correct 592 ms 2764 KB Output is correct
65 Correct 199 ms 1460 KB Output is correct
66 Correct 234 ms 1532 KB Output is correct
67 Correct 592 ms 2564 KB Output is correct
68 Correct 194 ms 2132 KB Output is correct
69 Execution timed out 1086 ms 5540 KB Time limit exceeded
70 Halted 0 ms 0 KB -