Submission #522707

# Submission time Handle Problem Language Result Execution time Memory
522707 2022-02-05T13:35:16 Z dostigator Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 3140 KB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
#define IShowSpeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcnt __builtin_popcount
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define mii map<int,int>
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define pb push_back
#define vt vector
#define endl '\n'
#define X first
#define Y second
typedef long double ld;
typedef long long ll;
const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=1e6;
const ll mod=1e9+7,inf=1e18;
int dp[N];
void solve(){
    int n;
    cin>>n;
    int a[n+2],sum=0;
    for(int i=1; i<=n; ++i) {cin>>a[i];sum+=a[i];}
    dp[0]=1;
    mii used;
    for(int j=1; j<=n; ++j) for(int i=500*500; i>=a[j]; --i) dp[i]+=dp[i-a[j]];
    if(!dp[sum/2] || sum%2){
        cout<<0<<endl;
        return;
    }
    vt<int>res;
    for(int i=1; i<=n; ++i){
        for(int j=a[i]; j<=500*500; ++j) dp[j]-=dp[j-a[i]];
        for(int nd=1; nd<=sum; ++nd){
            int h=sum-a[i];
            h+=nd;
            if(h%2 || !dp[h/2]) continue;
            used[nd]++;
            if(used[nd]==n)res.pb(nd);
        }
        for(int j=500*500; j>=a[i]; --j) dp[j]+=dp[j-a[i]];
    }
    cout<<res.size()<<endl;
    for(int x:res)cout<<x<<' ';
}
int main() {
    IShowSpeed;
    int tt=1;
    //cin>>tt;
    while(tt--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
11 Correct 13 ms 1228 KB Output is correct
12 Correct 9 ms 1320 KB Output is correct
13 Correct 12 ms 1316 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 13 ms 1280 KB Output is correct
16 Correct 14 ms 1216 KB Output is correct
17 Correct 8 ms 1300 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 16 ms 1308 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
11 Correct 13 ms 1228 KB Output is correct
12 Correct 9 ms 1320 KB Output is correct
13 Correct 12 ms 1316 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 13 ms 1280 KB Output is correct
16 Correct 14 ms 1216 KB Output is correct
17 Correct 8 ms 1300 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 16 ms 1308 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 23 ms 1364 KB Output is correct
22 Correct 27 ms 1308 KB Output is correct
23 Correct 15 ms 1364 KB Output is correct
24 Correct 40 ms 1356 KB Output is correct
25 Correct 47 ms 1484 KB Output is correct
26 Correct 53 ms 1496 KB Output is correct
27 Correct 34 ms 1384 KB Output is correct
28 Correct 36 ms 1388 KB Output is correct
29 Correct 40 ms 1356 KB Output is correct
30 Correct 47 ms 1484 KB Output is correct
31 Correct 50 ms 1460 KB Output is correct
32 Correct 47 ms 1416 KB Output is correct
33 Correct 17 ms 1228 KB Output is correct
34 Correct 19 ms 1304 KB Output is correct
35 Correct 35 ms 1356 KB Output is correct
36 Correct 46 ms 1424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
11 Correct 13 ms 1228 KB Output is correct
12 Correct 9 ms 1320 KB Output is correct
13 Correct 12 ms 1316 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 13 ms 1280 KB Output is correct
16 Correct 14 ms 1216 KB Output is correct
17 Correct 8 ms 1300 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 16 ms 1308 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 23 ms 1364 KB Output is correct
22 Correct 27 ms 1308 KB Output is correct
23 Correct 15 ms 1364 KB Output is correct
24 Correct 40 ms 1356 KB Output is correct
25 Correct 47 ms 1484 KB Output is correct
26 Correct 53 ms 1496 KB Output is correct
27 Correct 34 ms 1384 KB Output is correct
28 Correct 36 ms 1388 KB Output is correct
29 Correct 40 ms 1356 KB Output is correct
30 Correct 47 ms 1484 KB Output is correct
31 Correct 50 ms 1460 KB Output is correct
32 Correct 47 ms 1416 KB Output is correct
33 Correct 17 ms 1228 KB Output is correct
34 Correct 19 ms 1304 KB Output is correct
35 Correct 35 ms 1356 KB Output is correct
36 Correct 46 ms 1424 KB Output is correct
37 Correct 234 ms 1868 KB Output is correct
38 Correct 237 ms 1876 KB Output is correct
39 Correct 57 ms 1300 KB Output is correct
40 Correct 515 ms 2192 KB Output is correct
41 Correct 68 ms 1304 KB Output is correct
42 Correct 449 ms 2116 KB Output is correct
43 Correct 823 ms 2884 KB Output is correct
44 Correct 805 ms 2964 KB Output is correct
45 Correct 819 ms 3012 KB Output is correct
46 Correct 277 ms 1932 KB Output is correct
47 Correct 484 ms 2180 KB Output is correct
48 Correct 667 ms 2804 KB Output is correct
49 Correct 466 ms 2376 KB Output is correct
50 Correct 491 ms 2304 KB Output is correct
51 Correct 16 ms 1228 KB Output is correct
52 Execution timed out 1014 ms 3140 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
11 Correct 13 ms 1228 KB Output is correct
12 Correct 9 ms 1320 KB Output is correct
13 Correct 12 ms 1316 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 13 ms 1280 KB Output is correct
16 Correct 14 ms 1216 KB Output is correct
17 Correct 8 ms 1300 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 16 ms 1308 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 23 ms 1364 KB Output is correct
22 Correct 27 ms 1308 KB Output is correct
23 Correct 15 ms 1364 KB Output is correct
24 Correct 40 ms 1356 KB Output is correct
25 Correct 47 ms 1484 KB Output is correct
26 Correct 53 ms 1496 KB Output is correct
27 Correct 34 ms 1384 KB Output is correct
28 Correct 36 ms 1388 KB Output is correct
29 Correct 40 ms 1356 KB Output is correct
30 Correct 47 ms 1484 KB Output is correct
31 Correct 50 ms 1460 KB Output is correct
32 Correct 47 ms 1416 KB Output is correct
33 Correct 17 ms 1228 KB Output is correct
34 Correct 19 ms 1304 KB Output is correct
35 Correct 35 ms 1356 KB Output is correct
36 Correct 46 ms 1424 KB Output is correct
37 Correct 234 ms 1868 KB Output is correct
38 Correct 237 ms 1876 KB Output is correct
39 Correct 57 ms 1300 KB Output is correct
40 Correct 515 ms 2192 KB Output is correct
41 Correct 68 ms 1304 KB Output is correct
42 Correct 449 ms 2116 KB Output is correct
43 Correct 823 ms 2884 KB Output is correct
44 Correct 805 ms 2964 KB Output is correct
45 Correct 819 ms 3012 KB Output is correct
46 Correct 277 ms 1932 KB Output is correct
47 Correct 484 ms 2180 KB Output is correct
48 Correct 667 ms 2804 KB Output is correct
49 Correct 466 ms 2376 KB Output is correct
50 Correct 491 ms 2304 KB Output is correct
51 Correct 16 ms 1228 KB Output is correct
52 Execution timed out 1014 ms 3140 KB Time limit exceeded
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1228 KB Output is correct
2 Correct 4 ms 1216 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 2 ms 1228 KB Output is correct
5 Correct 4 ms 1228 KB Output is correct
6 Correct 3 ms 1228 KB Output is correct
7 Correct 2 ms 1228 KB Output is correct
8 Correct 3 ms 1228 KB Output is correct
9 Correct 3 ms 1248 KB Output is correct
10 Correct 8 ms 1228 KB Output is correct
11 Correct 13 ms 1228 KB Output is correct
12 Correct 9 ms 1320 KB Output is correct
13 Correct 12 ms 1316 KB Output is correct
14 Correct 14 ms 1304 KB Output is correct
15 Correct 13 ms 1280 KB Output is correct
16 Correct 14 ms 1216 KB Output is correct
17 Correct 8 ms 1300 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 16 ms 1308 KB Output is correct
20 Correct 5 ms 1228 KB Output is correct
21 Correct 23 ms 1364 KB Output is correct
22 Correct 27 ms 1308 KB Output is correct
23 Correct 15 ms 1364 KB Output is correct
24 Correct 40 ms 1356 KB Output is correct
25 Correct 47 ms 1484 KB Output is correct
26 Correct 53 ms 1496 KB Output is correct
27 Correct 34 ms 1384 KB Output is correct
28 Correct 36 ms 1388 KB Output is correct
29 Correct 40 ms 1356 KB Output is correct
30 Correct 47 ms 1484 KB Output is correct
31 Correct 50 ms 1460 KB Output is correct
32 Correct 47 ms 1416 KB Output is correct
33 Correct 17 ms 1228 KB Output is correct
34 Correct 19 ms 1304 KB Output is correct
35 Correct 35 ms 1356 KB Output is correct
36 Correct 46 ms 1424 KB Output is correct
37 Correct 234 ms 1868 KB Output is correct
38 Correct 237 ms 1876 KB Output is correct
39 Correct 57 ms 1300 KB Output is correct
40 Correct 515 ms 2192 KB Output is correct
41 Correct 68 ms 1304 KB Output is correct
42 Correct 449 ms 2116 KB Output is correct
43 Correct 823 ms 2884 KB Output is correct
44 Correct 805 ms 2964 KB Output is correct
45 Correct 819 ms 3012 KB Output is correct
46 Correct 277 ms 1932 KB Output is correct
47 Correct 484 ms 2180 KB Output is correct
48 Correct 667 ms 2804 KB Output is correct
49 Correct 466 ms 2376 KB Output is correct
50 Correct 491 ms 2304 KB Output is correct
51 Correct 16 ms 1228 KB Output is correct
52 Execution timed out 1014 ms 3140 KB Time limit exceeded
53 Halted 0 ms 0 KB -