답안 #226048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226048 2020-04-22T11:44:46 Z brcode Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
556 ms 25424 KB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const long long MAXN = 2e6+5;
long long arr[MAXN];
long long dp[MAXN];
long long dp2[MAXN];
vector<long long> v1;
int main(){
    long long ans = 0;
    long long n,m;
    cin>>n>>m;
    for(long long i=0;i<n;i++){
        cin>>arr[i];
    }
    for(long long i=0;i<(1LL<<(n/2));i++){
        for(long long j=0;j<(n/2);j++){
            if(i&(1LL<<j)){
                dp[i] += arr[j];
            }
        }
        v1.push_back(dp[i]);
    }
    sort(v1.begin(),v1.end());
    long long tmp = (n/2)+(n%2>0);
    for(long long i=0;i<(1LL<<(tmp));i++){
        for(long long j=0;j<(tmp);j++){
            if(i&(1LL<<j)){
                dp2[i] += arr[j+(n/2)];
            }
        }
        //cout<<dp2[i]<<endl;
    }

    for(long long i=0;i<(1LL<<(tmp));i++){
        long long target = m-dp2[i];

        if(target>=0){
            long long pos = upper_bound(v1.begin(),v1.end(),target)-v1.begin();
           //cout<<dp2[i]<<" "<<target<<" "<<pos<<endl;
            
            ans+=(pos);
        }
    }

   
    cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 2552 KB Output is correct
2 Correct 112 ms 6628 KB Output is correct
3 Correct 538 ms 25168 KB Output is correct
4 Correct 113 ms 6628 KB Output is correct
5 Correct 19 ms 2040 KB Output is correct
6 Correct 12 ms 1276 KB Output is correct
7 Correct 18 ms 2040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 3572 KB Output is correct
2 Correct 39 ms 2552 KB Output is correct
3 Correct 208 ms 12764 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 11 ms 1276 KB Output is correct
6 Correct 21 ms 2040 KB Output is correct
7 Correct 18 ms 2040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 4588 KB Output is correct
2 Correct 179 ms 8876 KB Output is correct
3 Correct 167 ms 8676 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 93 ms 8676 KB Output is correct
6 Correct 271 ms 25424 KB Output is correct
7 Correct 82 ms 8804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 381 ms 16868 KB Output is correct
2 Correct 36 ms 2552 KB Output is correct
3 Correct 15 ms 1276 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 12 ms 1276 KB Output is correct
6 Correct 202 ms 16860 KB Output is correct
7 Correct 18 ms 2040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2552 KB Output is correct
2 Correct 109 ms 6628 KB Output is correct
3 Correct 14 ms 1276 KB Output is correct
4 Correct 14 ms 1276 KB Output is correct
5 Correct 103 ms 8676 KB Output is correct
6 Correct 26 ms 2552 KB Output is correct
7 Correct 250 ms 25168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 430 ms 25168 KB Output is correct
2 Correct 40 ms 2552 KB Output is correct
3 Correct 15 ms 1276 KB Output is correct
4 Correct 556 ms 25228 KB Output is correct
5 Correct 132 ms 12764 KB Output is correct
6 Correct 22 ms 2040 KB Output is correct
7 Correct 40 ms 3564 KB Output is correct