# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549333 | krit3379 | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 497 ms | 8636 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;
#define N 1005
long long k,c,sum,ans;
vector<long long> a,b,v;
int main(){
int n,i,j;
scanf("%d %lld",&n,&k);
for(i=1;i<=n/2;i++)scanf("%lld",&c),a.push_back(c);
n-=n/2;
for(i=1;i<=n;i++)scanf("%lld",&c),b.push_back(c);
n=a.size();
for(i=0;i<1<<n;i++){
sum=0;
for(j=0;j<n;j++){
if(i&(1<<j))sum+=a[j];
}
v.push_back(sum);
}
sort(v.begin(),v.end());
n=b.size();
for(i=0;i<1<<n;i++){
sum=0;
for(j=0;j<n;j++){
if(i&(1<<j))sum+=b[j];
}
ans+=upper_bound(v.begin(),v.end(),k-sum)-v.begin();
}
printf("%lld",ans);
return 0;
}
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... |