Submission #162354

# Submission time Handle Problem Language Result Execution time Memory
162354 2019-11-07T16:46:37 Z dolphingarlic Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
463 ms 21008 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll a[40];

vector<ll> bitmask(int x, int y) {
    int r = y - x;
    vector<ll> ret;
    FOR(i, 0, (1 << r)) {
        ll sm = 0;
        FOR(j, 0, r) if (i & (1 << j)) sm += a[x + j];
        ret.push_back(sm);
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll b;
    cin >> n >> b;
    FOR(i, 0, n) cin >> a[i];

    vector<ll> l = bitmask(0, n / 2), r = bitmask(n / 2, n);
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());

    ll ans = 0;
    for (ll i : l) {
        if (i > b) break;
        ans += upper_bound(r.begin(), r.end(), b - i) - r.begin();
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2036 KB Output is correct
2 Correct 115 ms 5480 KB Output is correct
3 Correct 459 ms 21008 KB Output is correct
4 Correct 107 ms 5480 KB Output is correct
5 Correct 20 ms 1652 KB Output is correct
6 Correct 12 ms 1020 KB Output is correct
7 Correct 23 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2928 KB Output is correct
2 Correct 38 ms 2052 KB Output is correct
3 Correct 186 ms 10588 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 10 ms 1016 KB Output is correct
6 Correct 25 ms 1652 KB Output is correct
7 Correct 23 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 3572 KB Output is correct
2 Correct 158 ms 6648 KB Output is correct
3 Correct 157 ms 6632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 108 ms 6888 KB Output is correct
6 Correct 402 ms 20820 KB Output is correct
7 Correct 141 ms 6632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 327 ms 12812 KB Output is correct
2 Correct 37 ms 2036 KB Output is correct
3 Correct 14 ms 1016 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 11 ms 1016 KB Output is correct
6 Correct 325 ms 12760 KB Output is correct
7 Correct 22 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2032 KB Output is correct
2 Correct 113 ms 5484 KB Output is correct
3 Correct 13 ms 1016 KB Output is correct
4 Correct 13 ms 1016 KB Output is correct
5 Correct 114 ms 6632 KB Output is correct
6 Correct 36 ms 2200 KB Output is correct
7 Correct 393 ms 20888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 20960 KB Output is correct
2 Correct 39 ms 2032 KB Output is correct
3 Correct 14 ms 1012 KB Output is correct
4 Correct 463 ms 20872 KB Output is correct
5 Correct 157 ms 10592 KB Output is correct
6 Correct 24 ms 1688 KB Output is correct
7 Correct 44 ms 2924 KB Output is correct