Submission #90738

# Submission time Handle Problem Language Result Execution time Memory
90738 2018-12-24T08:02:50 Z FutymyClone Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
360 ms 17436 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 45;

int n;
long long a[N], m;
long long lef[1 << 20], rig[1 << 20], cntlef = 0, cntrig = 0;

int main(){
    scanf("%d %lld", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 0; i < (1 << (n / 2)); i++) {
        long long sum = 0;
        for (int j = 0; j < n / 2; j++) if (i & (1 << j)) sum += a[j + 1];
        lef[cntlef++] = sum;
    }

    for (int i = 0; i < (1 << (n - n / 2)); i++) {
        long long sum = 0;
        for (int j = 0; j < n - n / 2; j++) if (i & (1 << j)) sum += a[j + 1 + n / 2];
        rig[cntrig++] = sum;
    }

    sort(lef, lef + cntlef); sort(rig, rig + cntrig);
    long long ans = 0;
    for (int i = 0; i < cntlef; i++) ans += upper_bound(rig, rig + cntrig, m - lef[i]) - rig;
    printf("%lld", ans);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:12: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:13:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
                                  ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 720 KB Output is correct
2 Correct 2 ms 720 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 2 ms 720 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 2 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 792 KB Output is correct
2 Correct 2 ms 800 KB Output is correct
3 Correct 2 ms 804 KB Output is correct
4 Correct 2 ms 812 KB Output is correct
5 Correct 2 ms 812 KB Output is correct
6 Correct 2 ms 812 KB Output is correct
7 Correct 2 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2360 KB Output is correct
2 Correct 84 ms 4936 KB Output is correct
3 Correct 355 ms 17236 KB Output is correct
4 Correct 84 ms 17236 KB Output is correct
5 Correct 16 ms 17236 KB Output is correct
6 Correct 10 ms 17236 KB Output is correct
7 Correct 19 ms 17236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 17236 KB Output is correct
2 Correct 30 ms 17236 KB Output is correct
3 Correct 148 ms 17236 KB Output is correct
4 Correct 2 ms 17236 KB Output is correct
5 Correct 8 ms 17236 KB Output is correct
6 Correct 20 ms 17236 KB Output is correct
7 Correct 19 ms 17236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 17236 KB Output is correct
2 Correct 121 ms 17236 KB Output is correct
3 Correct 123 ms 17236 KB Output is correct
4 Correct 2 ms 17236 KB Output is correct
5 Correct 82 ms 17236 KB Output is correct
6 Correct 308 ms 17436 KB Output is correct
7 Correct 118 ms 17436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 255 ms 17436 KB Output is correct
2 Correct 29 ms 17436 KB Output is correct
3 Correct 11 ms 17436 KB Output is correct
4 Correct 2 ms 17436 KB Output is correct
5 Correct 9 ms 17436 KB Output is correct
6 Correct 247 ms 17436 KB Output is correct
7 Correct 19 ms 17436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 17436 KB Output is correct
2 Correct 83 ms 17436 KB Output is correct
3 Correct 11 ms 17436 KB Output is correct
4 Correct 11 ms 17436 KB Output is correct
5 Correct 87 ms 17436 KB Output is correct
6 Correct 30 ms 17436 KB Output is correct
7 Correct 319 ms 17436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 17436 KB Output is correct
2 Correct 30 ms 17436 KB Output is correct
3 Correct 10 ms 17436 KB Output is correct
4 Correct 360 ms 17436 KB Output is correct
5 Correct 119 ms 17436 KB Output is correct
6 Correct 20 ms 17436 KB Output is correct
7 Correct 39 ms 17436 KB Output is correct