Submission #850959

# Submission time Handle Problem Language Result Execution time Memory
850959 2023-09-18T03:35:16 Z Nhoksocqt1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
314 ms 10704 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll cost[40], m;
int nArr;

void process() {
    cin >> nArr >> m;
    for (int i = 0; i < nArr; ++i)
        cin >> cost[i];

    ll res(0);
    vector<ll> p;
    int n1 = min(nArr, 20), n2 = nArr - n1;
    for (int mask = 0; mask < (1 << n1); ++mask) {
        ll sum(0);
        for (int i1 = mask; i1 > 0; i1 ^= i1 & -i1) {
            int i = __builtin_ctz(i1 & -i1);
            sum += cost[i];
        }

        p.push_back(sum);
    }

    sort(p.begin(), p.end());
    for (int mask = 0; mask < (1 << n2); ++mask) {
        ll sum(0);
        for (int i1 = mask; i1 > 0; i1 ^= i1 & -i1) {
            int i = __builtin_ctz(i1 & -i1);
            sum += cost[20 + i];
        }

        int pos = upper_bound(p.begin(), p.end(), m - sum) - p.begin();
        res += pos;
    }

    cout << res << '\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    process();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 0 ms 464 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1496 KB Output is correct
2 Correct 5 ms 992 KB Output is correct
3 Correct 10 ms 1500 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 992 KB Output is correct
6 Correct 88 ms 9936 KB Output is correct
7 Correct 10 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 9168 KB Output is correct
2 Correct 21 ms 2520 KB Output is correct
3 Correct 5 ms 992 KB Output is correct
4 Correct 5 ms 992 KB Output is correct
5 Correct 49 ms 9936 KB Output is correct
6 Correct 10 ms 1500 KB Output is correct
7 Correct 10 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 8908 KB Output is correct
2 Correct 100 ms 9844 KB Output is correct
3 Correct 303 ms 10192 KB Output is correct
4 Correct 99 ms 9932 KB Output is correct
5 Correct 46 ms 8912 KB Output is correct
6 Correct 67 ms 9284 KB Output is correct
7 Correct 90 ms 10188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 8908 KB Output is correct
2 Correct 86 ms 9936 KB Output is correct
3 Correct 126 ms 10700 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 41 ms 10192 KB Output is correct
6 Correct 75 ms 8656 KB Output is correct
7 Correct 87 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 9168 KB Output is correct
2 Correct 114 ms 9164 KB Output is correct
3 Correct 112 ms 9424 KB Output is correct
4 Correct 21 ms 2516 KB Output is correct
5 Correct 48 ms 10192 KB Output is correct
6 Correct 110 ms 10192 KB Output is correct
7 Correct 90 ms 9168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 10444 KB Output is correct
2 Correct 87 ms 9676 KB Output is correct
3 Correct 86 ms 10192 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 53 ms 9160 KB Output is correct
6 Correct 106 ms 8908 KB Output is correct
7 Correct 87 ms 9344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 9676 KB Output is correct
2 Correct 98 ms 10448 KB Output is correct
3 Correct 85 ms 9680 KB Output is correct
4 Correct 88 ms 10704 KB Output is correct
5 Correct 64 ms 9676 KB Output is correct
6 Correct 87 ms 8912 KB Output is correct
7 Correct 115 ms 8908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 9168 KB Output is correct
2 Correct 88 ms 9680 KB Output is correct
3 Correct 88 ms 8912 KB Output is correct
4 Correct 314 ms 8908 KB Output is correct
5 Correct 64 ms 9108 KB Output is correct
6 Correct 87 ms 10192 KB Output is correct
7 Correct 87 ms 10192 KB Output is correct