Submission #972723

# Submission time Handle Problem Language Result Execution time Memory
972723 2024-05-01T04:37:31 Z blackslex Ice Hockey World Championship (CEOI15_bobek) C++17
0 / 100
312 ms 22844 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];
            }
            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 = (lower_bound(cr.begin(), cr.end(), m) - cr.begin()) + (lower_bound(cl.begin(), cl.end(), m) - cl.begin()) - 1;
    for (auto &e: cl) {
        auto lower = lower_bound(cr.begin(), cr.end(), m - e);
        if (*lower > e) 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 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 1 ms 640 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 24 ms 2064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 3020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 3664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 14656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 312 ms 22844 KB Output isn't correct
2 Halted 0 ms 0 KB -