# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161817 | dantoh000 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 456 ms | 8700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;
ll m;
scanf("%d%lld",&n,&m);
ll a[n];
for (int i = 0; i < n; i++) scanf("%lld",&a[i]);
int ct = 0;
int k = min(20,n-1);
vector<ll> v(1<<k);
for (int i = 0; i < (1<<k); i++){
int cur = i;
ll sum = 0;
while (cur){
int lsb = (cur)&(-cur);
sum += a[__builtin_ctz(lsb)];
cur -= lsb;
}
v[i] = sum;
}
sort(v.begin(),v.end());
ll ans = 0;
for (int i = 0; i < (1<<(n-k)); i++){
int cur = i;
ll sum = 0;
while (cur){
int lsb = (cur)&(-cur);
sum += a[__builtin_ctz(lsb)+k];
cur -= lsb;
}
//printf("%d %lld %lld\n",i,sum,(ll)(upper_bound(v.begin(),v.end(),m-sum)-v.begin()));
ans += upper_bound(v.begin(),v.end(),m-sum)-v.begin();
}
printf("%lld\n",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |