Submission #445911

# Submission time Handle Problem Language Result Execution time Memory
445911 2021-07-20T07:27:38 Z snasibov05 Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
443 ms 16756 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define pb push_back

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

    int mid = (n-1) / 2;
    vector<ll> p1;

    p1.pb(0);
    for (int i = 0; i < (1 << (mid+1)); ++i) {
        ll sum = 0;
        int x = i;
        for (int j = 0; j <= mid; ++j) {
            if (x % 2 == 1) sum += v[j];
            x /= 2;
        }
        if (sum <= m) p1.pb(sum);
    }

    sort(p1.begin(), p1.end());

    ll ans = p1.size();
    for (int i = 0; i < (1 << (n - mid - 1)); ++i) {
        ll sum = 0;
        int x = i;
        for (int j = mid + 1; j < n; ++j) {
            if (x % 2 == 1) sum += v[j];
            x /= 2;
        }
        if (sum > m) continue;
        int k = upper_bound(p1.begin(), p1.end(), m - sum) - p1.begin();
        ans += 1ll * k;
    }

    ans /= 2;

    cout << ans << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 310 ms 8628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 2368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 443 ms 16756 KB Output isn't correct
2 Halted 0 ms 0 KB -