# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121586 | vjudge1 | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 362 ms | 20900 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>
#define ll long long
#define endl "\n";
#define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
AI
ll n,m,i;
cin>>n>>m;
ll a[n];
for(i=0;i<n;i++)
cin>>a[i];
vector<ll>h1;
vector<ll>h2;
for(ll mask=0;mask<(1<<(n/2));mask++)
{
ll sum=0;
for(ll i=0;i<n/2;i++)//0 1 2
{
if(mask&(1<<i))
sum+=a[i];
}
if(sum<=m)
h1.push_back(sum);
}
for(ll mask=0;mask<(1<<(n/2+n%2));mask++)
{
ll sum=0;
for(ll i=0;i<n/2+n%2;i++)//
{
if(mask&(1<<i))
sum+=a[n/2+i];
}
// cout<<mask<<' '<<sum<<endl;
if(sum<=m)
h2.push_back(sum);
}
sort(h1.begin(),h1.end());
sort(h2.begin(),h2.end());
ll say=0;
/* for(i=0;i<h1.size();i++)
cout<<h1[i]<<' ';
cout<<endl;
for(i=0;i<h2.size();i++)
cout<<h2[i]<<' ';*/
for(i=0;i<h1.size();i++)
say+=upper_bound(h2.begin(),h2.end(),m-h1[i])-h2.begin();
cout<<say;
}
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... |