답안 #638769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638769 2022-09-07T11:35:44 Z HossamHero7 Ice Hockey World Championship (CEOI15_bobek) C++14
70 / 100
1000 ms 74448 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<ll> 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);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 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 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 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 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1268 KB Output is correct
2 Correct 300 ms 13040 KB Output is correct
3 Execution timed out 1059 ms 33328 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 1848 KB Output is correct
2 Correct 81 ms 4092 KB Output is correct
3 Correct 178 ms 1048 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 5 ms 324 KB Output is correct
6 Correct 20 ms 2352 KB Output is correct
7 Correct 33 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 8072 KB Output is correct
2 Correct 351 ms 9172 KB Output is correct
3 Correct 355 ms 9236 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 64 ms 312 KB Output is correct
6 Correct 249 ms 1936 KB Output is correct
7 Correct 190 ms 18820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 37372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 5080 KB Output is correct
2 Correct 362 ms 18968 KB Output is correct
3 Correct 18 ms 2644 KB Output is correct
4 Correct 21 ms 2760 KB Output is correct
5 Correct 76 ms 320 KB Output is correct
6 Correct 34 ms 5080 KB Output is correct
7 Correct 1000 ms 74448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 74320 KB Time limit exceeded
2 Halted 0 ms 0 KB -