# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
858959 | Tenis0206 | Ice Hockey World Championship (CEOI15_bobek) | C++11 | 283 ms | 22212 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 int long long
using namespace std;
const int nmax = 40;
int n;
long long m;
int v[nmax + 5];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>v[i];
}
int sz_a = n / 2;
int sz_b = n - sz_a;
vector<long long> a,b;
for(int mask=0;mask<(1<<sz_a);mask++)
{
long long sum = 0;
for(int b=0;b<sz_a;b++)
{
if((mask & (1<<b))!=0)
{
sum += v[b + 1];
}
}
a.push_back(sum);
}
for(int mask=0;mask<(1<<sz_b);mask++)
{
long long sum = 0;
for(int b=0;b<sz_b;b++)
{
if((mask & (1<<b))!=0)
{
sum += v[sz_a + b + 1];
}
}
b.push_back(sum);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int poz = b.size() - 1;
long long rez = 0;
for(int i=0;i<a.size();i++)
{
while(poz >= 0 && a[i] + b[poz] > m)
{
--poz;
}
rez += poz + 1;
}
cout<<rez<<'\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... |