Submission #1005104

# Submission time Handle Problem Language Result Execution time Memory
1005104 2024-06-22T07:13:50 Z Essa2006 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
316 ms 16864 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)

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

    int n;
    ll m;
    cin >> n >> m;

    vector<ll> C(n);
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }

    array<int, 2> sz = {n / 2, (n + 1) / 2};
    array<vector<ll>, 2> A;
    A[0].clear(), A[1].clear();
    A[0].reserve(1 << 20), A[1].reserve(1 << 20);

    for (int j = 0; j < 2; j++) {
        int shift = (j ? sz[j - 1] : 0);

        for (int msk = 1; msk < (1 << sz[j]); msk++) {

            int cur = msk;
            A[j].push_back(C[__builtin_ctz (msk) + shift]);
            cur = cur & (cur - 1);
            while (cur) {
                A[j].back() += (C[__builtin_ctz(cur) + shift]);
                cur = cur & (cur - 1);
            }

        }

    }
    sort(all(A[1]));
    A[0].push_back(0);

    ll ans = 0;
    for (int i = 0; i < A[0].size(); i++) {
        if (A[0][i] > m) {
            continue;
        }
        ans++;
        int ind = upper_bound(all(A[1]), m - A[0][i]) - A[1].begin();
        ans += ind;
    }
    cout << ans;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 0; i < A[0].size(); i++) {
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 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 16 ms 2016 KB Output is correct
2 Correct 61 ms 8376 KB Output is correct
3 Correct 316 ms 16860 KB Output is correct
4 Correct 61 ms 7260 KB Output is correct
5 Correct 5 ms 1372 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 7 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 4956 KB Output is correct
2 Correct 16 ms 1880 KB Output is correct
3 Correct 124 ms 12088 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 7 ms 5220 KB Output is correct
7 Correct 5 ms 1504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 6236 KB Output is correct
2 Correct 88 ms 10332 KB Output is correct
3 Correct 87 ms 10588 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 35 ms 7016 KB Output is correct
6 Correct 109 ms 16800 KB Output is correct
7 Correct 41 ms 9096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 14428 KB Output is correct
2 Correct 15 ms 1880 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 864 KB Output is correct
6 Correct 99 ms 13156 KB Output is correct
7 Correct 5 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3428 KB Output is correct
2 Correct 58 ms 7516 KB Output is correct
3 Correct 5 ms 860 KB Output is correct
4 Correct 7 ms 856 KB Output is correct
5 Correct 34 ms 9920 KB Output is correct
6 Correct 11 ms 1884 KB Output is correct
7 Correct 90 ms 16728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 209 ms 16864 KB Output is correct
2 Correct 18 ms 3676 KB Output is correct
3 Correct 6 ms 856 KB Output is correct
4 Correct 288 ms 16864 KB Output is correct
5 Correct 44 ms 9052 KB Output is correct
6 Correct 9 ms 4444 KB Output is correct
7 Correct 10 ms 5620 KB Output is correct