답안 #972728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972728 2024-05-01T04:53:23 Z blackslex Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
368 ms 22836 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 upper = upper_bound(cr.begin(), cr.end(), m - e); upper = prev(upper);
        ans += (upper - 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);
      |                      ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 344 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 412 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1876 KB Output is correct
2 Correct 85 ms 5420 KB Output is correct
3 Correct 368 ms 22836 KB Output is correct
4 Correct 80 ms 5316 KB Output is correct
5 Correct 13 ms 1944 KB Output is correct
6 Correct 9 ms 984 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 2768 KB Output is correct
2 Correct 32 ms 1880 KB Output is correct
3 Correct 136 ms 11136 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 7 ms 1096 KB Output is correct
6 Correct 17 ms 1492 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3412 KB Output is correct
2 Correct 118 ms 8344 KB Output is correct
3 Correct 117 ms 8252 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 78 ms 7956 KB Output is correct
6 Correct 292 ms 21420 KB Output is correct
7 Correct 50 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 14396 KB Output is correct
2 Correct 27 ms 2132 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 984 KB Output is correct
6 Correct 233 ms 14024 KB Output is correct
7 Correct 8 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 1880 KB Output is correct
2 Correct 78 ms 5312 KB Output is correct
3 Correct 9 ms 980 KB Output is correct
4 Correct 9 ms 984 KB Output is correct
5 Correct 85 ms 8504 KB Output is correct
6 Correct 26 ms 1880 KB Output is correct
7 Correct 138 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 327 ms 21652 KB Output is correct
2 Correct 28 ms 1876 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 356 ms 21008 KB Output is correct
5 Correct 111 ms 12212 KB Output is correct
6 Correct 17 ms 1492 KB Output is correct
7 Correct 16 ms 348 KB Output is correct