# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
86599 | rzbt | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 403 ms | 21424 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 mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;
using namespace std;
ll n,m;
vector<ll> tekme1,tekme2,svi1,svi2;
using namespace std;
int main()
{
scanf("%lld %lld", &n, &m);
for(int i=0;i<n;i++){
ll t;
scanf("%lld", &t);
if(i%2==0)tekme1.pb(t);
else tekme2.pb(t);
}
int gran=1<<tekme1.size();
for(int i=0;i<gran;i++){
ll ts=0;
for(int j=0;j<tekme1.size();j++){
if((i>>j)&1)ts+=tekme1[j];
}
svi1.pb(ts);
}
gran=1<<tekme2.size();
for(int i=0;i<gran;i++){
ll ts=0;
for(int j=0;j<tekme2.size();j++){
if((i>>j)&1)ts+=tekme2[j];
}
svi2.pb(ts);
}
sort(all(svi1));
sort(all(svi2));
ll j=svi2.size()-1,res=0;
for(ll i=0;i<svi1.size();i++){
while(svi1[i]+svi2[j]>m && j>=0)j--;
//printf("%lld %lld\n",i,j);
if(j==-1)break;
res+=j+1ll;
}
printf("%lld",res);
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... |