Submission #101755

# Submission time Handle Problem Language Result Execution time Memory
101755 2019-03-20T00:27:19 Z shenxy Ice Hockey World Championship (CEOI15_bobek) C++11
10 / 100
577 ms 8640 KB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N;
    long long int M;
    scanf("%d %lld", &N, &M);
    long long int mycosts[N];
    for (int i = 0; i < N; i++) scanf("%lld", &mycosts[i]);
    vector<long long int> thecosts;
    for (long long int mask = 0; mask < (1 << (N / 2)); mask++) {
        long long int ans = 0;
        for (int i = 0; i < N / 2; i++) {
            if (mask & (1 << i)) ans += mycosts[i];
        }
        thecosts.push_back(ans);
    }
    sort(thecosts.begin(), thecosts.end());
    long long int trueans = 0;
    for (long long int mask = 0; mask < (1 << (N - N / 2)); mask++) {
        long long int ans = 0;
        for (int i = 0; i < N - N / 2; i++) {
            if (mask & (1 << i)) ans += mycosts[i];
        }
        trueans += upper_bound(thecosts.begin(), thecosts.end(), M - ans) - thecosts.begin();
    }
    printf("%lld", trueans);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:8: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:10:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < N; i++) scanf("%lld", &mycosts[i]);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 1400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 389 ms 4616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 577 ms 8640 KB Output isn't correct
2 Halted 0 ms 0 KB -