답안 #101761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101761 2019-03-20T01:00:26 Z rocketninja7 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
234 ms 16860 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int N;
    long long int M;
    scanf("%d%lld", &N, &M);
    long long int A[N];
    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
    }
    long long int sums1[1<<(N/2)];
    for(int i=0;i<(1<<(N/2));i++){
        sums1[i]=1000000000000000001;
        long long int temp=0;
        long long int tempI=i;
        while(tempI>0){
            temp+=A[__builtin_ctz(tempI)];
            if(temp>M){
                break;
            }
            tempI-=tempI&-tempI;
        }
        if(temp<=M){
            sums1[i]=temp;
        }
    }
    long long int sums2[1<<(N-N/2)];
    for(int i=0;i<(1<<(N-N/2));i++){
        sums2[i]=1000000000000000001;
        long long int temp=0;
        long long int tempI=i;
        while(tempI>0){
            temp+=A[__builtin_ctz(tempI)+N/2];
            if(temp>M){
                break;
            }
            tempI-=tempI&-tempI;
        }
        if(temp<=M){
            sums2[i]=temp;
        }
    }
    sort(sums1, sums1+(1<<(N/2)));
    sort(sums2, sums2+(1<<(N-N/2)));
    long long int ans=0;
    int ri=(1<<(N-N/2))-1;
    for(int i=0;i<(1<<(N/2));i++){
        while(ri>-1&&sums1[i]+sums2[ri]>M){
            ri--;
        }
        ans+=ri+1;
    }
    printf("%lld", ans);
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:7: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:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &A[i]);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 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 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1792 KB Output is correct
2 Correct 49 ms 4352 KB Output is correct
3 Correct 231 ms 16776 KB Output is correct
4 Correct 53 ms 4352 KB Output is correct
5 Correct 12 ms 1280 KB Output is correct
6 Correct 7 ms 768 KB Output is correct
7 Correct 6 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2420 KB Output is correct
2 Correct 20 ms 1920 KB Output is correct
3 Correct 87 ms 8668 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 13 ms 1408 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3328 KB Output is correct
2 Correct 91 ms 6528 KB Output is correct
3 Correct 77 ms 6400 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 39 ms 6528 KB Output is correct
6 Correct 168 ms 16860 KB Output is correct
7 Correct 20 ms 6528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 12652 KB Output is correct
2 Correct 21 ms 1920 KB Output is correct
3 Correct 8 ms 896 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 6 ms 896 KB Output is correct
6 Correct 163 ms 12536 KB Output is correct
7 Correct 4 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1792 KB Output is correct
2 Correct 48 ms 4352 KB Output is correct
3 Correct 8 ms 896 KB Output is correct
4 Correct 7 ms 768 KB Output is correct
5 Correct 53 ms 6528 KB Output is correct
6 Correct 17 ms 1792 KB Output is correct
7 Correct 59 ms 16760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 212 ms 16756 KB Output is correct
2 Correct 19 ms 1792 KB Output is correct
3 Correct 8 ms 896 KB Output is correct
4 Correct 234 ms 16760 KB Output is correct
5 Correct 71 ms 8440 KB Output is correct
6 Correct 12 ms 1408 KB Output is correct
7 Correct 7 ms 2304 KB Output is correct