이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Ali
// #pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ins insert
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 3e5+23, inf = 2e9, LG = 19,pr = 31;
void fast(){
int n,k;
cin>>n>>k;
vector<int> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
int ans=0;
vector<int> a,b;
for(int i=0;i<n/2;i++){
a.pb(arr[i]);
}
for(int j=n/2;j<n;j++){
b.pb(arr[j]);
}
vector<int> al,bl;
for(int mask =0;mask<(1<< (a.size() ));mask++){
int sum=0;
for(int i =0;i<30;i++){
if(mask & (1<<i)){
sum+=a[i];
}
}
al.pb(sum);
}
for(int mask =0;mask<(1<< (b.size() ));mask++){
int sum=0;
for(int i =0;i<30;i++){
if(mask & (1<<i)){
sum+=b[i];
}
}
bl.pb(sum);
}
// sort(all(al));
sort(all(bl));
for(auto v:al){
int lazim = k - v;
ans+= upper_bound(all(bl),lazim) - bl.begin();
}
putr(ans);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
fast();
}
return 0;
}
# | 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... |