이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define co cout<<
#define ll long long
using namespace std;
//stuff
void solve(){
ll n,k;
cin>>n>>k;
ll arr[n+5];
vector<ll>v;
for(int i=0;i<n;i++) cin>>arr[i];
ll n1=n/2,ans=0;
for(int i=0;i<exp2(n1);i++){
ll sum=0;
ll x=i;
for(int j=0;j<n1;j++) if(((x>>j)&1)) sum+=arr[j];
v.push_back(sum);
}
sort(v.begin(),v.end());
for(int i=0;i<exp2(n-n1);i++){
ll sum=0;
ll x=i;
for(int j=0;j<n-n1;j++) if(((x>>j)&1)) sum+=arr[j+n1];
ans+=upper_bound(v.begin(),v.end(),k-sum)-v.begin();
}
co ans<<'\n';
}
int main(){
suiii
int _=1;
// cin>>_;
while(_--) solve();
}
# | 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... |