Submission #101753

# Submission time Handle Problem Language Result Execution time Memory
101753 2019-03-19T23:59:58 Z cheeheng Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
406 ms 20944 KB
#include <bits/stdc++.h>

using namespace std;

long long A[45];

int main(){
    int N; long long M;
    scanf("%d%lld", &N, &M);

    for(int i = 0; i < N; i ++){
        scanf("%lld", &A[i]);
    }

    if(N <= 20){
        vector<long long> sum1;
        for(int i = 0; i < (1<<N); i ++){
            long long temp = 0;
            for(int j = 0; j < N; j ++){
                if(i&(1<<j)){
                    temp += A[j];
                }
            }
            sum1.push_back(temp);
        }
        sort(sum1.begin(), sum1.end());
        printf("%lld", (long long)(upper_bound(sum1.begin(), sum1.end(), M)-sum1.begin()));
    }else{
        vector<long long> sum1;
        for(int i = 0; i < (1<<20); i ++){
            long long temp = 0;
            for(int j = 0; j < 20; j ++){
                if(i&(1<<j)){
                    temp += A[j];
                }
            }
            sum1.push_back(temp);
        }
        vector<long long> sum2;
        for(int i = 0; i < (1<<(N-20)); i ++){
            long long temp = 0;
            for(int j = 0; j < (N-20); j ++){
                if(i&(1<<j)){
                    temp += A[j+20];
                }
            }
            sum2.push_back(temp);
        }
        sort(sum1.begin(), sum1.end());
        sort(sum2.begin(), sum2.end());
        long long ans = 0;
        for(int i = 0; i < (1<<20); i ++){
            ans += upper_bound(sum2.begin(), sum2.end(), M-sum1[i])-sum2.begin();
        }
        printf("%lld", ans);
    }
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:9: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:12: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 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1528 KB Output is correct
2 Correct 12 ms 1020 KB Output is correct
3 Correct 25 ms 1528 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 9 ms 892 KB Output is correct
6 Correct 187 ms 8668 KB Output is correct
7 Correct 19 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 190 ms 8624 KB Output is correct
2 Correct 41 ms 2548 KB Output is correct
3 Correct 12 ms 1016 KB Output is correct
4 Correct 11 ms 1020 KB Output is correct
5 Correct 162 ms 8784 KB Output is correct
6 Correct 24 ms 1528 KB Output is correct
7 Correct 23 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 8672 KB Output is correct
2 Correct 218 ms 9584 KB Output is correct
3 Correct 406 ms 20820 KB Output is correct
4 Correct 219 ms 9552 KB Output is correct
5 Correct 158 ms 8672 KB Output is correct
6 Correct 180 ms 8672 KB Output is correct
7 Correct 186 ms 8668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 8876 KB Output is correct
2 Correct 207 ms 8796 KB Output is correct
3 Correct 208 ms 12624 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 282 ms 8668 KB Output is correct
6 Correct 187 ms 8784 KB Output is correct
7 Correct 187 ms 8676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 9068 KB Output is correct
2 Correct 219 ms 10596 KB Output is correct
3 Correct 223 ms 10588 KB Output is correct
4 Correct 40 ms 2548 KB Output is correct
5 Correct 156 ms 10576 KB Output is correct
6 Correct 353 ms 20944 KB Output is correct
7 Correct 207 ms 10568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 16848 KB Output is correct
2 Correct 211 ms 8776 KB Output is correct
3 Correct 199 ms 8668 KB Output is correct
4 Correct 8 ms 640 KB Output is correct
5 Correct 153 ms 8756 KB Output is correct
6 Correct 304 ms 16912 KB Output is correct
7 Correct 192 ms 8668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 8748 KB Output is correct
2 Correct 219 ms 9552 KB Output is correct
3 Correct 186 ms 8668 KB Output is correct
4 Correct 181 ms 8784 KB Output is correct
5 Correct 185 ms 10576 KB Output is correct
6 Correct 195 ms 8692 KB Output is correct
7 Correct 384 ms 20816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 399 ms 20788 KB Output is correct
2 Correct 197 ms 8672 KB Output is correct
3 Correct 196 ms 8848 KB Output is correct
4 Correct 406 ms 20816 KB Output is correct
5 Correct 182 ms 12624 KB Output is correct
6 Correct 200 ms 8696 KB Output is correct
7 Correct 183 ms 8912 KB Output is correct