답안 #638762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638762 2022-09-07T11:00:22 Z HossamHero7 Ice Hockey World Championship (CEOI15_bobek) C++14
40 / 100
1000 ms 70100 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    for(auto &i:v) cin>>i;
    map<ll,ll> frq;
    for(int mask=0;mask<(1<<n/2);mask++){
        ll sum = 0;
        for(int i=0;i<n/2;i++){
            if((1<<i)&mask){
                sum += v[i];
            }
        }
        frq[sum] ++;
    }
    ll prev = 0;
    vector<int> tmp;
    for(auto &i : frq){
        i.second += prev;
        tmp.push_back(i.first);
        prev = i.second;
    }
    int rem = n-n/2;
    ll ans = 0;
    for(int mask=0;mask<(1<<rem);mask++){
        ll sum = 0;
        for(int i=0;i<rem;i++){
            if((1<<i)&mask){
                sum += v[n/2+i];
            }
        }
        if(sum > m) continue;
        int upper = upper_bound(tmp.begin(),tmp.end(),m-sum) - tmp.begin();
        upper --;
        ans += frq[tmp[upper]];
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 1164 KB Output is correct
2 Correct 275 ms 12012 KB Output is correct
3 Execution timed out 1080 ms 31168 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 1620 KB Output is correct
2 Correct 64 ms 3796 KB Output is correct
3 Correct 205 ms 980 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 20 ms 2260 KB Output is correct
7 Correct 26 ms 4708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 175 ms 7624 KB Output is correct
2 Correct 389 ms 8724 KB Output is correct
3 Correct 311 ms 8728 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 62 ms 304 KB Output is correct
6 Correct 248 ms 1668 KB Output is correct
7 Correct 201 ms 17884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 456 ms 35324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 70100 KB Time limit exceeded
2 Halted 0 ms 0 KB -