Submission #1004997

# Submission time Handle Problem Language Result Execution time Memory
1004997 2024-06-22T05:57:51 Z SulA Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
319 ms 10436 KB
#include <bits/stdc++.h>
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    long long n; long long x; cin >> n >> x;
    long long a1[n/2], a2[(n+1)/2];
    for (auto& y : a1) cin >> y;
    for (auto& y : a2) cin >> y;
    vector<long long> half;

    for (long long mask = 0; mask < 1 << (n/2); mask++) {
        long long sum = 0;
        for (long long i = 0; i < n/2; i++) {
            if (mask & (1 << i)) {
                sum += a1[i];
            }
        }
        if (sum <= x) half.push_back(sum);
    }
    sort(half.begin(), half.end());

    long long cnt = 0;
    for (long long mask = 0; mask < (1 << ((n+1)/2)); mask++) {
        long long sum = 0;
        for (long long i = 0; i < (n+1)/2; i++) {
            if (mask & (1 << i)) {
                sum += a2[i];
            }
        }
        if (sum <= x) cnt += upper_bound(half.begin(), half.end(), x - sum) - half.begin();
    }
    cout << cnt;
}
# 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 0 ms 348 KB Output is correct
5 Correct 0 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 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 0 ms 348 KB Output is correct
5 Correct 0 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 0 ms 344 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 0 ms 348 KB Output is correct
7 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 988 KB Output is correct
2 Correct 87 ms 2520 KB Output is correct
3 Correct 291 ms 8896 KB Output is correct
4 Correct 68 ms 2520 KB Output is correct
5 Correct 11 ms 992 KB Output is correct
6 Correct 6 ms 736 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1500 KB Output is correct
2 Correct 27 ms 992 KB Output is correct
3 Correct 147 ms 5840 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 11 ms 992 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1500 KB Output is correct
2 Correct 111 ms 2516 KB Output is correct
3 Correct 118 ms 2516 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 57 ms 2656 KB Output is correct
6 Correct 177 ms 10436 KB Output is correct
7 Correct 41 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 6100 KB Output is correct
2 Correct 22 ms 988 KB Output is correct
3 Correct 8 ms 736 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 736 KB Output is correct
6 Correct 134 ms 4956 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 992 KB Output is correct
2 Correct 70 ms 2516 KB Output is correct
3 Correct 7 ms 732 KB Output is correct
4 Correct 7 ms 736 KB Output is correct
5 Correct 72 ms 2524 KB Output is correct
6 Correct 17 ms 992 KB Output is correct
7 Correct 114 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 303 ms 10188 KB Output is correct
2 Correct 24 ms 988 KB Output is correct
3 Correct 8 ms 732 KB Output is correct
4 Correct 319 ms 10184 KB Output is correct
5 Correct 90 ms 6612 KB Output is correct
6 Correct 12 ms 992 KB Output is correct
7 Correct 14 ms 456 KB Output is correct