Submission #650286

# Submission time Handle Problem Language Result Execution time Memory
650286 2022-10-13T10:35:38 Z sofija6 Bootfall (IZhO17_bootfall) C++14
100 / 100
756 ms 4180 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 510
#define MAXS 250010
#define MOD 1000000007
using namespace std;
ll dp[MAXS],sum,a[MAXN];
bool yes[MAXS];
void Add(ll x)
{
    for (ll i=MAXS-5;i>=x;i--)
        dp[i]=(dp[i]+dp[i-x])%MOD;
}
void Remove(ll x)
{
    for (ll i=x;i<=MAXS-5;i++)
        dp[i]=(dp[i]-dp[i-x]+MOD)%MOD;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    dp[0]=1;
    for (ll i=1;i<=n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for (ll i=1;i<=n;i++)
        Add(a[i]);
    if (sum&1 || !dp[sum/2])
    {
        cout << 0 << "\n";
        return 0;
    }
    for (ll i=1;i<MAXS;i++)
        yes[i]=true;
    for (ll i=1;i<=n;i++)
    {
        Remove(a[i]);
        for (ll j=1;j<MAXS;j++)
        {
            if (!yes[j])
                continue;
            if ((sum+j-a[i])&1 || !dp[(sum+j-a[i])/2])
                yes[j]=false;
        }
        Add(a[i]);
    }
    vector<ll> ans;
    for (ll i=1;i<MAXS;i++)
    {
        if (yes[i])
            ans.push_back(i);
    }
    cout << ans.size() << "\n";
    for (ll i=0;i<ans.size();i++)
        cout << ans[i] << " ";
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:58:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (ll i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
10 Correct 45 ms 2504 KB Output is correct
11 Correct 50 ms 2516 KB Output is correct
12 Correct 45 ms 2516 KB Output is correct
13 Correct 41 ms 2516 KB Output is correct
14 Correct 56 ms 2504 KB Output is correct
15 Correct 50 ms 2508 KB Output is correct
16 Correct 54 ms 2516 KB Output is correct
17 Correct 30 ms 2516 KB Output is correct
18 Correct 38 ms 2508 KB Output is correct
19 Correct 44 ms 2508 KB Output is correct
20 Correct 47 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
10 Correct 45 ms 2504 KB Output is correct
11 Correct 50 ms 2516 KB Output is correct
12 Correct 45 ms 2516 KB Output is correct
13 Correct 41 ms 2516 KB Output is correct
14 Correct 56 ms 2504 KB Output is correct
15 Correct 50 ms 2508 KB Output is correct
16 Correct 54 ms 2516 KB Output is correct
17 Correct 30 ms 2516 KB Output is correct
18 Correct 38 ms 2508 KB Output is correct
19 Correct 44 ms 2508 KB Output is correct
20 Correct 47 ms 2412 KB Output is correct
21 Correct 99 ms 2540 KB Output is correct
22 Correct 107 ms 2512 KB Output is correct
23 Correct 77 ms 2512 KB Output is correct
24 Correct 136 ms 2508 KB Output is correct
25 Correct 139 ms 2528 KB Output is correct
26 Correct 139 ms 2524 KB Output is correct
27 Correct 142 ms 2504 KB Output is correct
28 Correct 141 ms 2520 KB Output is correct
29 Correct 145 ms 2520 KB Output is correct
30 Correct 139 ms 2508 KB Output is correct
31 Correct 137 ms 2504 KB Output is correct
32 Correct 150 ms 2508 KB Output is correct
33 Correct 145 ms 2508 KB Output is correct
34 Correct 136 ms 2508 KB Output is correct
35 Correct 142 ms 2512 KB Output is correct
36 Correct 147 ms 2504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
10 Correct 45 ms 2504 KB Output is correct
11 Correct 50 ms 2516 KB Output is correct
12 Correct 45 ms 2516 KB Output is correct
13 Correct 41 ms 2516 KB Output is correct
14 Correct 56 ms 2504 KB Output is correct
15 Correct 50 ms 2508 KB Output is correct
16 Correct 54 ms 2516 KB Output is correct
17 Correct 30 ms 2516 KB Output is correct
18 Correct 38 ms 2508 KB Output is correct
19 Correct 44 ms 2508 KB Output is correct
20 Correct 47 ms 2412 KB Output is correct
21 Correct 99 ms 2540 KB Output is correct
22 Correct 107 ms 2512 KB Output is correct
23 Correct 77 ms 2512 KB Output is correct
24 Correct 136 ms 2508 KB Output is correct
25 Correct 139 ms 2528 KB Output is correct
26 Correct 139 ms 2524 KB Output is correct
27 Correct 142 ms 2504 KB Output is correct
28 Correct 141 ms 2520 KB Output is correct
29 Correct 145 ms 2520 KB Output is correct
30 Correct 139 ms 2508 KB Output is correct
31 Correct 137 ms 2504 KB Output is correct
32 Correct 150 ms 2508 KB Output is correct
33 Correct 145 ms 2508 KB Output is correct
34 Correct 136 ms 2508 KB Output is correct
35 Correct 142 ms 2512 KB Output is correct
36 Correct 147 ms 2504 KB Output is correct
37 Correct 280 ms 2656 KB Output is correct
38 Correct 283 ms 2776 KB Output is correct
39 Correct 345 ms 2524 KB Output is correct
40 Correct 372 ms 2780 KB Output is correct
41 Correct 389 ms 2512 KB Output is correct
42 Correct 349 ms 2764 KB Output is correct
43 Correct 338 ms 2928 KB Output is correct
44 Correct 357 ms 2920 KB Output is correct
45 Correct 346 ms 2912 KB Output is correct
46 Correct 384 ms 2396 KB Output is correct
47 Correct 353 ms 2780 KB Output is correct
48 Correct 349 ms 2912 KB Output is correct
49 Correct 346 ms 2532 KB Output is correct
50 Correct 345 ms 2764 KB Output is correct
51 Correct 101 ms 2268 KB Output is correct
52 Correct 375 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
10 Correct 45 ms 2504 KB Output is correct
11 Correct 50 ms 2516 KB Output is correct
12 Correct 45 ms 2516 KB Output is correct
13 Correct 41 ms 2516 KB Output is correct
14 Correct 56 ms 2504 KB Output is correct
15 Correct 50 ms 2508 KB Output is correct
16 Correct 54 ms 2516 KB Output is correct
17 Correct 30 ms 2516 KB Output is correct
18 Correct 38 ms 2508 KB Output is correct
19 Correct 44 ms 2508 KB Output is correct
20 Correct 47 ms 2412 KB Output is correct
21 Correct 99 ms 2540 KB Output is correct
22 Correct 107 ms 2512 KB Output is correct
23 Correct 77 ms 2512 KB Output is correct
24 Correct 136 ms 2508 KB Output is correct
25 Correct 139 ms 2528 KB Output is correct
26 Correct 139 ms 2524 KB Output is correct
27 Correct 142 ms 2504 KB Output is correct
28 Correct 141 ms 2520 KB Output is correct
29 Correct 145 ms 2520 KB Output is correct
30 Correct 139 ms 2508 KB Output is correct
31 Correct 137 ms 2504 KB Output is correct
32 Correct 150 ms 2508 KB Output is correct
33 Correct 145 ms 2508 KB Output is correct
34 Correct 136 ms 2508 KB Output is correct
35 Correct 142 ms 2512 KB Output is correct
36 Correct 147 ms 2504 KB Output is correct
37 Correct 280 ms 2656 KB Output is correct
38 Correct 283 ms 2776 KB Output is correct
39 Correct 345 ms 2524 KB Output is correct
40 Correct 372 ms 2780 KB Output is correct
41 Correct 389 ms 2512 KB Output is correct
42 Correct 349 ms 2764 KB Output is correct
43 Correct 338 ms 2928 KB Output is correct
44 Correct 357 ms 2920 KB Output is correct
45 Correct 346 ms 2912 KB Output is correct
46 Correct 384 ms 2396 KB Output is correct
47 Correct 353 ms 2780 KB Output is correct
48 Correct 349 ms 2912 KB Output is correct
49 Correct 346 ms 2532 KB Output is correct
50 Correct 345 ms 2764 KB Output is correct
51 Correct 101 ms 2268 KB Output is correct
52 Correct 375 ms 3036 KB Output is correct
53 Correct 446 ms 2896 KB Output is correct
54 Correct 493 ms 3020 KB Output is correct
55 Correct 514 ms 3276 KB Output is correct
56 Correct 429 ms 3024 KB Output is correct
57 Correct 504 ms 3272 KB Output is correct
58 Correct 487 ms 3048 KB Output is correct
59 Correct 507 ms 3180 KB Output is correct
60 Correct 174 ms 2268 KB Output is correct
61 Correct 488 ms 3160 KB Output is correct
62 Correct 460 ms 3276 KB Output is correct
63 Correct 450 ms 3292 KB Output is correct
64 Correct 490 ms 3388 KB Output is correct
65 Correct 450 ms 2508 KB Output is correct
66 Correct 433 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2504 KB Output is correct
2 Correct 11 ms 2516 KB Output is correct
3 Correct 3 ms 2260 KB Output is correct
4 Correct 8 ms 2532 KB Output is correct
5 Correct 21 ms 2528 KB Output is correct
6 Correct 14 ms 2516 KB Output is correct
7 Correct 11 ms 2516 KB Output is correct
8 Correct 21 ms 2516 KB Output is correct
9 Correct 17 ms 2516 KB Output is correct
10 Correct 45 ms 2504 KB Output is correct
11 Correct 50 ms 2516 KB Output is correct
12 Correct 45 ms 2516 KB Output is correct
13 Correct 41 ms 2516 KB Output is correct
14 Correct 56 ms 2504 KB Output is correct
15 Correct 50 ms 2508 KB Output is correct
16 Correct 54 ms 2516 KB Output is correct
17 Correct 30 ms 2516 KB Output is correct
18 Correct 38 ms 2508 KB Output is correct
19 Correct 44 ms 2508 KB Output is correct
20 Correct 47 ms 2412 KB Output is correct
21 Correct 99 ms 2540 KB Output is correct
22 Correct 107 ms 2512 KB Output is correct
23 Correct 77 ms 2512 KB Output is correct
24 Correct 136 ms 2508 KB Output is correct
25 Correct 139 ms 2528 KB Output is correct
26 Correct 139 ms 2524 KB Output is correct
27 Correct 142 ms 2504 KB Output is correct
28 Correct 141 ms 2520 KB Output is correct
29 Correct 145 ms 2520 KB Output is correct
30 Correct 139 ms 2508 KB Output is correct
31 Correct 137 ms 2504 KB Output is correct
32 Correct 150 ms 2508 KB Output is correct
33 Correct 145 ms 2508 KB Output is correct
34 Correct 136 ms 2508 KB Output is correct
35 Correct 142 ms 2512 KB Output is correct
36 Correct 147 ms 2504 KB Output is correct
37 Correct 280 ms 2656 KB Output is correct
38 Correct 283 ms 2776 KB Output is correct
39 Correct 345 ms 2524 KB Output is correct
40 Correct 372 ms 2780 KB Output is correct
41 Correct 389 ms 2512 KB Output is correct
42 Correct 349 ms 2764 KB Output is correct
43 Correct 338 ms 2928 KB Output is correct
44 Correct 357 ms 2920 KB Output is correct
45 Correct 346 ms 2912 KB Output is correct
46 Correct 384 ms 2396 KB Output is correct
47 Correct 353 ms 2780 KB Output is correct
48 Correct 349 ms 2912 KB Output is correct
49 Correct 346 ms 2532 KB Output is correct
50 Correct 345 ms 2764 KB Output is correct
51 Correct 101 ms 2268 KB Output is correct
52 Correct 375 ms 3036 KB Output is correct
53 Correct 446 ms 2896 KB Output is correct
54 Correct 493 ms 3020 KB Output is correct
55 Correct 514 ms 3276 KB Output is correct
56 Correct 429 ms 3024 KB Output is correct
57 Correct 504 ms 3272 KB Output is correct
58 Correct 487 ms 3048 KB Output is correct
59 Correct 507 ms 3180 KB Output is correct
60 Correct 174 ms 2268 KB Output is correct
61 Correct 488 ms 3160 KB Output is correct
62 Correct 460 ms 3276 KB Output is correct
63 Correct 450 ms 3292 KB Output is correct
64 Correct 490 ms 3388 KB Output is correct
65 Correct 450 ms 2508 KB Output is correct
66 Correct 433 ms 2644 KB Output is correct
67 Correct 587 ms 3168 KB Output is correct
68 Correct 223 ms 2268 KB Output is correct
69 Correct 738 ms 4056 KB Output is correct
70 Correct 715 ms 3548 KB Output is correct
71 Correct 721 ms 3408 KB Output is correct
72 Correct 671 ms 2504 KB Output is correct
73 Correct 688 ms 2504 KB Output is correct
74 Correct 738 ms 4180 KB Output is correct
75 Correct 743 ms 3812 KB Output is correct
76 Correct 756 ms 4060 KB Output is correct
77 Correct 739 ms 4172 KB Output is correct