답안 #638773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638773 2022-09-07T11:44:08 Z HossamHero7 Ice Hockey World Championship (CEOI15_bobek) C++14
70 / 100
1000 ms 74488 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,int> frq;
    for(int mask=0;mask<(1<<n/2);mask++){
        ll sum = 0;
        for(int i=0;i<(n>>1);i++){
            if((1<<i)&mask){
                sum += v[i];
            }
        }
        frq[sum] ++;
    }
    int prev = 0;
    vector<ll> tmp;
    for(auto &i : frq){
        i.second += prev;
        tmp.push_back(i.first);
        prev = i.second;
    }
    int rem = n-(n>>1);
    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>>1)+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 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 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 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 212 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1296 KB Output is correct
2 Correct 291 ms 13080 KB Output is correct
3 Execution timed out 1087 ms 33224 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 1876 KB Output is correct
2 Correct 68 ms 4116 KB Output is correct
3 Correct 176 ms 1152 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 27 ms 2340 KB Output is correct
7 Correct 26 ms 4920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 147 ms 8152 KB Output is correct
2 Correct 380 ms 9168 KB Output is correct
3 Correct 453 ms 9284 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 63 ms 300 KB Output is correct
6 Correct 265 ms 1880 KB Output is correct
7 Correct 189 ms 18912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1096 ms 37336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 4976 KB Output is correct
2 Correct 352 ms 18912 KB Output is correct
3 Correct 17 ms 2772 KB Output is correct
4 Correct 23 ms 2672 KB Output is correct
5 Correct 75 ms 328 KB Output is correct
6 Correct 38 ms 5044 KB Output is correct
7 Correct 994 ms 74212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 74488 KB Time limit exceeded
2 Halted 0 ms 0 KB -