Submission #528827

# Submission time Handle Problem Language Result Execution time Memory
528827 2022-02-21T14:20:41 Z perchuts Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
482 ms 8800 KB
#include <bits/stdc++.h>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define pb push_back
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf 2000000001
#define mod 1000000007 //998244353
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

int n;
ll m, c[50];    

vector<ll>rsums;

ll generate(int x,int flag){
    int st = ((n+1)/2)*flag;
    ll sum = 0;
    while(x){
        if(x&1)sum += c[st];
        st++;
        x>>=1;
    }
    return sum;
}

int main(){_
    cin>>n>>m;
    for(int i=0;i<n;++i)cin>>c[i];

    for(int i=0;i<(1<<(n/2));++i)rsums.pb(generate(i,1));
    sort(all(rsums));
    ll ans = 0;

    auto binsearch = [&](ll x){
        int l = 0, r = sz(rsums)-1, ans = -1;
        while(l<=r){
            int md = l + (r-l+1)/2;
            if(rsums[md]<=x)ans = md, l = md + 1;
            else r = md - 1;
        }
        return ans+1;
    };

    for(int i=0;i<(1<<((n+1)/2));++i){
        ll lsum = generate(i,0);
        ans += 1LL*binsearch(m-lsum);
    }

    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 848 KB Output is correct
2 Correct 99 ms 2508 KB Output is correct
3 Correct 482 ms 8636 KB Output is correct
4 Correct 88 ms 2508 KB Output is correct
5 Correct 16 ms 852 KB Output is correct
6 Correct 6 ms 596 KB Output is correct
7 Correct 13 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1484 KB Output is correct
2 Correct 29 ms 852 KB Output is correct
3 Correct 170 ms 4552 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 6 ms 596 KB Output is correct
6 Correct 13 ms 980 KB Output is correct
7 Correct 14 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1444 KB Output is correct
2 Correct 144 ms 2508 KB Output is correct
3 Correct 151 ms 2488 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 81 ms 2416 KB Output is correct
6 Correct 208 ms 8800 KB Output is correct
7 Correct 74 ms 2400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 302 ms 4528 KB Output is correct
2 Correct 27 ms 852 KB Output is correct
3 Correct 9 ms 596 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 7 ms 596 KB Output is correct
6 Correct 148 ms 4528 KB Output is correct
7 Correct 13 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 944 KB Output is correct
2 Correct 87 ms 2484 KB Output is correct
3 Correct 9 ms 596 KB Output is correct
4 Correct 9 ms 596 KB Output is correct
5 Correct 103 ms 2516 KB Output is correct
6 Correct 18 ms 852 KB Output is correct
7 Correct 232 ms 8568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 8648 KB Output is correct
2 Correct 31 ms 964 KB Output is correct
3 Correct 9 ms 632 KB Output is correct
4 Correct 464 ms 8620 KB Output is correct
5 Correct 124 ms 4528 KB Output is correct
6 Correct 13 ms 980 KB Output is correct
7 Correct 26 ms 1468 KB Output is correct