이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long long+
int main(){
ll n, m, n1, n2;
cin>>n>>m;
n1 = n / 2;
n2 = n - n1;
vector<ll> v1(n1, 0), v2(n2, 0);
for (int i = 0; i < n1; i++){
cin>>v1[i];
}
for (int i = 0; i < n2; i++){
cin>>v2[i];
}
vector<ll> ar1, ar2;
for (int i = 0; i < (1<<n1); i++){
ll su = 0;
for (int j = 0; j < n1; j++){
int val = i & (1<<j);
if (val != 0){
su += v1[j];
}
}
if (su <= m){
ar1.push_back(su);
}
}
for (int i = 0; i < (1<<n2); i++){
ll su = 0;
for (int j = 0; j < n2; j++){
int val = i & (1<<j);
if (val != 0){
su += v2[j];
}
}
if (su <= m){
ar2.push_back(su);
}
}
sort(ar1.begin(), ar1.end());
sort(ar2.begin(), ar2.end());
ll ans = 0;
for (auto el : ar1){
ll res = upper_bound(ar2.begin(), ar2.end(), m - el) - ar2.begin();
ans += res;
}
cout<<ans;
}
# | 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... |