Submission #638789

# Submission time Handle Problem Language Result Execution time Memory
638789 2022-09-07T13:47:00 Z HossamHero7 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
1000 ms 61016 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;
    unordered_map<ll,ll> 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){
        tmp.push_back(i.first);
    }
    sort(tmp.begin(),tmp.end());
    for(auto i : tmp){
        frq[i] += prev;
        prev = frq[i];
    }
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1084 KB Output is correct
2 Correct 141 ms 9940 KB Output is correct
3 Correct 673 ms 27900 KB Output is correct
4 Correct 135 ms 12024 KB Output is correct
5 Correct 9 ms 328 KB Output is correct
6 Correct 5 ms 596 KB Output is correct
7 Correct 23 ms 4084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1368 KB Output is correct
2 Correct 37 ms 3404 KB Output is correct
3 Correct 96 ms 836 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 4 ms 324 KB Output is correct
6 Correct 14 ms 1968 KB Output is correct
7 Correct 21 ms 3940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 6848 KB Output is correct
2 Correct 153 ms 7468 KB Output is correct
3 Correct 148 ms 7592 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 55 ms 296 KB Output is correct
6 Correct 139 ms 1400 KB Output is correct
7 Correct 148 ms 15248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 892 ms 30516 KB Output is correct
2 Correct 40 ms 4068 KB Output is correct
3 Correct 15 ms 1952 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 393 ms 30464 KB Output is correct
7 Correct 24 ms 4076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 3984 KB Output is correct
2 Correct 208 ms 15312 KB Output is correct
3 Correct 14 ms 1968 KB Output is correct
4 Correct 16 ms 1968 KB Output is correct
5 Correct 60 ms 328 KB Output is correct
6 Correct 31 ms 4068 KB Output is correct
7 Correct 828 ms 60884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 61016 KB Time limit exceeded
2 Halted 0 ms 0 KB -