# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
928910 | Warinchai | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 300 ms | 21700 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>
#define int long long
using namespace std;
int ar[45];
vector<int>first;
vector<int>second;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m;cin>>n>>m;
int md=n/2;
int m2=n-md;
for(int i=1;i<=n;i++){
cin>>ar[i];
}
for(int i=0;i<(1<<md);i++){
int sum=0;
for(int j=0;j<md;j++){
if((i>>j)&1)sum+=ar[j+1];
}
//cerr<<i<<" "<<sum<<"\n";
if(sum<=m)first.push_back(sum);
}
for(int i=0;i<(1<<m2);i++){
int sum=0;
for(int j=0;j<m2;j++){
if((i>>j)&1)sum+=ar[md+j+1];
}
if(sum<=m)second.push_back(sum);
}
sort(first.begin(),first.end());
sort(second.begin(),second.end(),greater<int>());
/*for(auto x:first)cerr<<x<<" ";
cerr<<"\n";
for(auto x:second)cerr<<x<<" ";
cerr<<"\n";*/
int cur=0;
int ans=0;
for(auto x:first){
while(cur<second.size()&&x+second[cur]>m){
cur++;
}
ans+=second.size()-cur;
}
cout<<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... |