Submission #106820

# Submission time Handle Problem Language Result Execution time Memory
106820 2019-04-20T15:43:50 Z LamoreauxAJ Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
515 ms 4712 KB
#include <bits/stdc++.h>
using namespace std;

int N, M;
vector<int> nums;
vector<int> half;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("1.in", "r", stdin);

    cin >> N >> M;
    nums.assign(N, 0);
    for (int i = 0; i < N; i++)
        cin >> nums[i];

    for (int i = 0; i < (1 << (N / 2)); i++) {
        long long sum = 0;
        for (int j = 0; j < N / 2; j++)
            if (i & (1 << j))
                sum += nums[j];
        half.push_back(sum);
    }
    sort(half.begin(), half.end());

    long long res = 0;
    for (int i = 0; i < (1 << (N - N / 2)); i++) {
        long long sum = 0;
        for (int j = N / 2; j < N; j++)
            if (i & (1 << (j - N / 2)))
                sum += nums[j];

        int lo = 0, hi = half.size() - 1, ans = -1;
        while (lo <= hi) {
            int m = (lo + hi) / 2;
            if (half[m] > M - sum)
                hi = m - 1;
            else
                lo = m + 1, ans = m;
        }

        res += ans + 1;
    }

    cout << res << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 768 KB Output is correct
2 Correct 112 ms 1504 KB Output is correct
3 Correct 515 ms 4552 KB Output is correct
4 Correct 102 ms 1532 KB Output is correct
5 Correct 19 ms 768 KB Output is correct
6 Correct 9 ms 640 KB Output is correct
7 Correct 20 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1024 KB Output is correct
2 Correct 40 ms 768 KB Output is correct
3 Correct 193 ms 2596 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 9 ms 512 KB Output is correct
6 Correct 17 ms 768 KB Output is correct
7 Correct 18 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 1024 KB Output is correct
2 Correct 177 ms 1532 KB Output is correct
3 Correct 171 ms 1532 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 100 ms 1532 KB Output is correct
6 Correct 266 ms 4712 KB Output is correct
7 Correct 92 ms 1532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 160 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 4640 KB Output isn't correct
2 Halted 0 ms 0 KB -