Submission #972727

# Submission time Handle Problem Language Result Execution time Memory
972727 2024-05-01T04:48:08 Z blackslex Ice Hockey World Championship (CEOI15_bobek) C++17
10 / 100
331 ms 21760 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int n;
ll m;

int main() {
    scanf("%d %lld", &n, &m);
    vector<ll> a(n);
    for (auto &e: a) scanf("%lld", &e);
    auto get = [&] (int l, int r) {
        vector<ll> c;
        int sz = r - l + 1;
        for (int i = 0; i < (1 << sz); i++) {
            ll csum = 0;
            for (int j = 0; j < sz; j++) {
                if (i & (1 << j)) csum += a[j + l];
            }
            if (csum <= m) c.emplace_back(csum);
        }
        sort(c.begin(), c.end());
        return c;
    };
    int posl = 0, posr = n / 2;
    auto cl = get(posl, posr - 1), cr = get(posr, n - 1);
    ll ans = cl.size() + cr.size() - 1;
    for (auto &e: cl) {
        if (!e) continue;
        auto lower = lower_bound(cr.begin(), cr.end(), m - e);
        if (*lower > m - e && lower != cr.begin()) lower = prev(lower);
        ans += (lower - cr.begin());
    }
    printf("%lld", ans);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %lld", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (auto &e: a) scanf("%lld", &e);
      |                      ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 1964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 2768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 3516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 14120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 331 ms 21760 KB Output isn't correct
2 Halted 0 ms 0 KB -