Submission #380172

# Submission time Handle Problem Language Result Execution time Memory
380172 2021-03-20T12:45:26 Z vishesh312 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
504 ms 8848 KB
#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()

using ll = long long;
const int mod = 1e9+7;

void solve(int tc) {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n/2), b(n-n/2);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;
    n = sz(a);
    int m = sz(b);
    ll ans = 0;
    vector<ll> res;
    for (int mask = 0; mask < (1<<n); ++mask) {
        ll x = 0;
        for (int i = 0; i < n; ++i) if (mask&(1<<i)) x += a[i];
        if (x <= k) {
            res.push_back(x);
        }
    }
    sort(all(res));
    for (int mask = 0; mask < (1<<m); ++mask) {
        ll x = 0;
        for (int j = 0; j < m; ++j) if (mask&(1<<j)) x += b[j];
        ans += (upper_bound(all(res), k-x) - res.begin());
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int tc = 1;
    //cin >> tc;
    for (int i = 1; i <= tc; ++i) solve(i);
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1008 KB Output is correct
2 Correct 103 ms 2536 KB Output is correct
3 Correct 491 ms 8748 KB Output is correct
4 Correct 101 ms 2536 KB Output is correct
5 Correct 17 ms 1008 KB Output is correct
6 Correct 8 ms 772 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1516 KB Output is correct
2 Correct 35 ms 1008 KB Output is correct
3 Correct 209 ms 4580 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 8 ms 752 KB Output is correct
6 Correct 18 ms 1008 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1516 KB Output is correct
2 Correct 168 ms 2536 KB Output is correct
3 Correct 153 ms 2664 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 92 ms 2536 KB Output is correct
6 Correct 259 ms 8672 KB Output is correct
7 Correct 47 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 352 ms 4580 KB Output is correct
2 Correct 30 ms 1008 KB Output is correct
3 Correct 10 ms 752 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 8 ms 752 KB Output is correct
6 Correct 179 ms 4580 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1008 KB Output is correct
2 Correct 97 ms 2536 KB Output is correct
3 Correct 11 ms 752 KB Output is correct
4 Correct 11 ms 752 KB Output is correct
5 Correct 122 ms 2536 KB Output is correct
6 Correct 21 ms 1008 KB Output is correct
7 Correct 125 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 419 ms 8848 KB Output is correct
2 Correct 34 ms 1008 KB Output is correct
3 Correct 10 ms 752 KB Output is correct
4 Correct 504 ms 8672 KB Output is correct
5 Correct 140 ms 4712 KB Output is correct
6 Correct 15 ms 1008 KB Output is correct
7 Correct 15 ms 364 KB Output is correct