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 int long long
int min(int a,int b){
return (a < b ? a : b);
}
int max(int a,int b){
return (a > b ? a : b);
}
signed main(){
int n,m;
cin >> n >> m;
vector<int> sira(n);
for(auto &i : sira)cin >> i;
multiset<int> cvbs;
int fsst = min(20,n);
for(int mask=0;mask<(1 << fsst);++mask){
int curr = 0;
for(int i=0;i<fsst;++i){
if(mask & (1 << i))curr += sira[i];
}
if(curr > m)continue;
else cvbs.insert(curr);
}
fsst = n - 20;
int cvb=0;
fsst = max(fsst,0);
for(int mask=0;mask < (1 << fsst);++mask){
int curr = 0;
for(int i=20;i<n;++i){
if(mask & (1 << (i - 20)))curr +=sira[i];
}
if(curr > m)continue;
else{
cvb += *cvbs.upper_bound(m - curr);
}
}
cout << cvb;
}
# | 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... |