이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |