이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define fori for(int i=0;i<n;i++)
#define forj for(int j=0;j<n;j++)
#define pb push_back
#define in insert
#define F first
#define S second
#define endl '\n'
using namespace std;
int main(){
fast;
ll n,x;
cin>>n>>x;
vector<ll>v;
ll a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
ll sum,mid=n/2,mid2=n-mid;
ll ans=0;
for(int i=0;i<(1<<mid);i++){
sum=0;
for(int j=0;j<mid;j++){
if((i & (1<<j))!=0){
sum+=a[j];
}
}
v.pb(sum); //5
}
sort(v.begin(),v.end());
for(int i=0;i<(1<<mid2);i++){
sum=0;
for(int j=0;j<mid2;j++){
if((i & (1<<j))!=0){
sum+=a[j+mid];//10
}
}
auto q=upper_bound(v.begin(),v.end(),x-sum);
ans+=q - v.begin();
}
cout<<ans<<endl;
}
# | 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... |