# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1101393 | 0pt1mus23 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 324 ms | 22964 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ins insert
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
#define _ << " " <<
mt19937 rng(time(0));
const int mod = 1e9 +9,
sze = 2e5 +23,
inf = INT_MAX,
LL = 20;
void _0x0(){
int n,m;
cin>>n>>m;
vector<int> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
vector<int> lst;
vector<int> lst2;
int ans=1;
vector<int> a,b;
for(int i=0;i<n/2;i++){
a.pb(arr[i]);
}
for(int i =n/2;i<n;i++){
b.pb(arr[i]);
}
// for(auto v:a) cout<<v<<" ";cout<<endl;
// for(auto v:b) cout<<v<<" ";cout<<endl;
for(int mask=0;mask<(1<<(a.size()));mask++){
int sum=0;
for(int j=0;j<a.size();j++){
if(mask & (1<<j)){
sum+=a[j];
}
}
lst.pb(sum);
}
for(int mask=0;mask<(1<<(b.size()));mask++){
int sum=0;
for(int j=0;j<b.size();j++){
if(mask & (1<<j)){
sum+=b[j];
}
}
lst2.pb(sum);
}
sort(all(lst));
sort(all(lst2));
for(auto v:lst){
auto lazim = m - v;
if(lazim>=0){
ans+= ( upper_bound(all(lst2),lazim) - lst2.begin() ) ;
}
}
cout<<ans-1<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
_0x0();
}
return 0;
}
Compilation message (stderr)
# | 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... |