Submission #222247

# Submission time Handle Problem Language Result Execution time Memory
222247 2020-04-12T13:56:07 Z DodgeBallMan Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
405 ms 20884 KB
#include <bits/stdc++.h>

using namespace std;

int n;
long long m, va[2][25], s[2], ans;
vector<long long> all[2];

void permute( int ty ) {
    //printf("size %d\n",s[ty]);
    for( int i = 0 ; i < ( 1<<s[ty] ) ; i++ ) {
        long long sum = 0;
        for( int j = 0 ; j < s[ty] ; j++ ) if( i & ( 1<<j ) ) sum += va[ty][j];
        all[ty].emplace_back( sum );
    }
}

int main()
{
    scanf("%d %lld",&n,&m);
    s[0] = n/2;
    s[1] = n - s[0];
    for( int i = 0 ; i < s[0] ; i++ ) scanf("%lld",&va[0][i]);
    for( int i = 0 ; i < s[1] ; i++ ) scanf("%lld",&va[1][i]);
    permute( 0 ), permute( 1 );
    sort( all[0].begin(), all[0].end() ), sort( all[1].begin(), all[1].end() );
    for( long long i : all[0] ) {
        long long temp = m - i;
        int idx = upper_bound( all[1].begin(), all[1].end(), temp ) - all[1].begin();
        ans += ( long long )idx;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:20: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:23:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 0 ; i < s[0] ; i++ ) scanf("%lld",&va[0][i]);
                                       ~~~~~^~~~~~~~~~~~~~~~~~
bobek.cpp:24:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for( int i = 0 ; i < s[1] ; i++ ) scanf("%lld",&va[1][i]);
                                       ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 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 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory 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 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory 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 256 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
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2040 KB Output is correct
2 Correct 99 ms 5488 KB Output is correct
3 Correct 405 ms 20816 KB Output is correct
4 Correct 95 ms 5480 KB Output is correct
5 Correct 20 ms 1656 KB Output is correct
6 Correct 14 ms 1020 KB Output is correct
7 Correct 24 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2932 KB Output is correct
2 Correct 39 ms 2040 KB Output is correct
3 Correct 161 ms 10588 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 12 ms 1020 KB Output is correct
6 Correct 25 ms 1656 KB Output is correct
7 Correct 24 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 3572 KB Output is correct
2 Correct 144 ms 6628 KB Output is correct
3 Correct 141 ms 6628 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 92 ms 6628 KB Output is correct
6 Correct 347 ms 20816 KB Output is correct
7 Correct 132 ms 6628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 12756 KB Output is correct
2 Correct 37 ms 2040 KB Output is correct
3 Correct 15 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 277 ms 12764 KB Output is correct
7 Correct 23 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2040 KB Output is correct
2 Correct 100 ms 5432 KB Output is correct
3 Correct 16 ms 1020 KB Output is correct
4 Correct 15 ms 1020 KB Output is correct
5 Correct 100 ms 6632 KB Output is correct
6 Correct 35 ms 2040 KB Output is correct
7 Correct 367 ms 20816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 393 ms 20816 KB Output is correct
2 Correct 37 ms 2040 KB Output is correct
3 Correct 15 ms 1020 KB Output is correct
4 Correct 404 ms 20884 KB Output is correct
5 Correct 135 ms 10588 KB Output is correct
6 Correct 26 ms 1656 KB Output is correct
7 Correct 44 ms 2932 KB Output is correct