답안 #638771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638771 2022-09-07T11:38:37 Z HossamHero7 Ice Hockey World Championship (CEOI15_bobek) C++14
70 / 100
1000 ms 74368 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 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 0 ms 212 KB Output is correct
7 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 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 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 45 ms 1216 KB Output is correct
2 Correct 269 ms 13084 KB Output is correct
3 Execution timed out 1092 ms 33176 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 1796 KB Output is correct
2 Correct 61 ms 4052 KB Output is correct
3 Correct 173 ms 1152 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 21 ms 2440 KB Output is correct
7 Correct 27 ms 4908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 159 ms 8128 KB Output is correct
2 Correct 359 ms 9160 KB Output is correct
3 Correct 384 ms 9256 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 59 ms 212 KB Output is correct
6 Correct 253 ms 1820 KB Output is correct
7 Correct 218 ms 18952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 37284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 5052 KB Output is correct
2 Correct 331 ms 18884 KB Output is correct
3 Correct 17 ms 2644 KB Output is correct
4 Correct 18 ms 2772 KB Output is correct
5 Correct 74 ms 320 KB Output is correct
6 Correct 37 ms 4988 KB Output is correct
7 Correct 986 ms 74368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1098 ms 74292 KB Time limit exceeded
2 Halted 0 ms 0 KB -