# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963421 | pcc | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 302 ms | 21064 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 ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 40;
ll N,M;
vector<ll> lv,rv;
vector<ll> la,ra;
void calc(vector<ll> &v,vector<ll>& all){
for(int i = 0;i<(1<<v.size());i++){
ll sum = 0;
for(int j = 0;j<v.size();j++){
if(i&(1<<j))sum += v[j];
}
all.push_back(sum);
}
sort(all.begin(),all.end());
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<N/2;i++){
ll k;
cin>>k;
la.push_back(k);
}
for(int i = N/2;i<N;i++){
ll k;
cin>>k;
ra.push_back(k);
}
calc(la,lv);
calc(ra,rv);
ll pt = 0;
ll ans = 0;
reverse(lv.begin(),lv.end());
for(auto &i:lv){
while(pt<rv.size()&&rv[pt]+i<=M)pt++;
ans += pt;
}
cout<<ans<<'\n';
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... |