# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
738632 | bgnbvnbv | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 305 ms | 20840 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 TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll n,m,a[maxN];
vector<ll>vec1,vec2;
void solve()
{
cin >> n >> m;ll ans=0;
for(int i=1;i<=n;i++) cin >> a[i];
ll k=n/2;
for(int mask=0;mask<(1<<k);mask++)
{
ll sum=0;
for(int i=0;i<k;i++)
{
if(mask>>i&1)
{
sum+=a[i+1];
}
}
vec1.pb(sum);
}
for(int mask=0;mask<(1<<(n-k));mask++)
{
ll sum=0;
for(int i=0;i<n-k;i++)
{
if(mask>>i&1)
{
sum+=a[i+k+1];
}
}
vec2.pb(sum);
}
sort(vec1.begin(),vec1.end());
sort(vec2.begin(),vec2.end());
ll j=0;
for(int i=vec1.size()-1;i>=0;i--)
{
while(j<vec2.size()&&vec2[j]+vec1[i]<=m) j++;
ans+=j;
}
cout << ans;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
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... |