Submission #159217

# Submission time Handle Problem Language Result Execution time Memory
159217 2019-10-21T13:34:19 Z Akashi Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
409 ms 20920 KB
#include <bits/stdc++.h>
using namespace std;

int n, l;
long long m;
long long a[42];
vector <long long> v[2];

void back(int i, int n, long long Sum = 0){
    if(Sum > m) return ;
    if(i == n + 1){
        v[l].push_back(Sum);
        return ;
    }

    back(i + 1, n, Sum);
    back(i + 1, n, Sum + a[i]);
}

int main()
{
    scanf("%d%lld", &n, &m);
    for(int i = 1; i <= n ; ++i)
        scanf("%lld", &a[i]);

    l = 0;
    back(1, n / 2);

    l = 1;
    back(n / 2 + 1, n);

    sort(v[1].begin(), v[1].end());
    long long Sol = 0;
    for(auto it : v[0]){
        int pos = upper_bound(v[1].begin(), v[1].end(), m - it) - v[1].begin();
        Sol = Sol + pos;
    }

    printf("%lld", Sol);

    return 0;
}



















Compilation message

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:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         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 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2028 KB Output is correct
2 Correct 92 ms 5476 KB Output is correct
3 Correct 409 ms 20816 KB Output is correct
4 Correct 84 ms 5480 KB Output is correct
5 Correct 10 ms 1540 KB Output is correct
6 Correct 6 ms 888 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2924 KB Output is correct
2 Correct 27 ms 2032 KB Output is correct
3 Correct 188 ms 10716 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 5 ms 1012 KB Output is correct
6 Correct 11 ms 1648 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3560 KB Output is correct
2 Correct 118 ms 6628 KB Output is correct
3 Correct 124 ms 6624 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 47 ms 6624 KB Output is correct
6 Correct 174 ms 20816 KB Output is correct
7 Correct 2 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 278 ms 12760 KB Output is correct
2 Correct 26 ms 2024 KB Output is correct
3 Correct 10 ms 1012 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 1140 KB Output is correct
6 Correct 158 ms 12756 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2028 KB Output is correct
2 Correct 92 ms 5476 KB Output is correct
3 Correct 9 ms 1012 KB Output is correct
4 Correct 8 ms 1012 KB Output is correct
5 Correct 61 ms 6624 KB Output is correct
6 Correct 19 ms 2032 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 20816 KB Output is correct
2 Correct 28 ms 2028 KB Output is correct
3 Correct 9 ms 1012 KB Output is correct
4 Correct 398 ms 20920 KB Output is correct
5 Correct 73 ms 10588 KB Output is correct
6 Correct 12 ms 1648 KB Output is correct
7 Correct 2 ms 256 KB Output is correct