답안 #221858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221858 2020-04-11T10:25:47 Z PeppaPig Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
541 ms 20820 KB
#include <bits/stdc++.h>

#define long long long

using namespace std;

vector<long> process(vector<long> &v) {
    vector<long> ret;
    for(int i = 0; i < (1 << (int)v.size()); i++) {
        long now = 0;
        for(int j = 0; j < v.size(); j++) if(i >> j & 1)
            now += v[j];
        ret.emplace_back(now);
    }
    return ret;
}

int n;
long m;

int main() {
    scanf("%d %lld", &n, &m);
    vector<long> l, r;
    long a;
    for(int i = 1; i <= n / 2; i++) {
        scanf("%lld", &a);
        l.emplace_back(a);
    }
    for(int i = n / 2 + 1; i <= n; i++) {
        scanf("%lld", &a);
        r.emplace_back(a);
    }
    vector<long> sum_l = process(l);
    vector<long> sum_r = process(r);
    sort(sum_l.begin(), sum_l.end());

    long ans = 0;
    for(long x : sum_r)
        ans += upper_bound(sum_l.begin(), sum_l.end(), m - x) - sum_l.begin();
    printf("%lld\n", ans);

    return 0;
}

Compilation message

bobek.cpp: In function 'std::vector<long long int> process(std::vector<long long int>&)':
bobek.cpp:11:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < v.size(); j++) if(i >> j & 1)
                        ~~^~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a);
         ~~~~~^~~~~~~~~~~~
bobek.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 2040 KB Output is correct
2 Correct 121 ms 5608 KB Output is correct
3 Correct 525 ms 20816 KB Output is correct
4 Correct 110 ms 5480 KB Output is correct
5 Correct 21 ms 1656 KB Output is correct
6 Correct 13 ms 1148 KB Output is correct
7 Correct 20 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 2876 KB Output is correct
2 Correct 41 ms 2040 KB Output is correct
3 Correct 230 ms 10588 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 12 ms 1020 KB Output is correct
6 Correct 21 ms 1656 KB Output is correct
7 Correct 20 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 3564 KB Output is correct
2 Correct 189 ms 6688 KB Output is correct
3 Correct 182 ms 6628 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 98 ms 6632 KB Output is correct
6 Correct 289 ms 20820 KB Output is correct
7 Correct 93 ms 6632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 386 ms 12876 KB Output is correct
2 Correct 38 ms 2040 KB Output is correct
3 Correct 16 ms 1020 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 12 ms 1020 KB Output is correct
6 Correct 224 ms 12876 KB Output is correct
7 Correct 20 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2040 KB Output is correct
2 Correct 113 ms 5488 KB Output is correct
3 Correct 14 ms 1020 KB Output is correct
4 Correct 15 ms 1020 KB Output is correct
5 Correct 110 ms 6628 KB Output is correct
6 Correct 27 ms 2040 KB Output is correct
7 Correct 278 ms 20816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 437 ms 20816 KB Output is correct
2 Correct 41 ms 2040 KB Output is correct
3 Correct 15 ms 1020 KB Output is correct
4 Correct 541 ms 20816 KB Output is correct
5 Correct 134 ms 10592 KB Output is correct
6 Correct 21 ms 1656 KB Output is correct
7 Correct 37 ms 2932 KB Output is correct