# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
461293 | vanic | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 247 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 <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=45;
vector < ll > v[2];
int n;
ll m;
ll a[maxn];
ll pref[maxn];
ll sol;
int gran, ind;
void rijesi(int x, ll sum){
// cout << x << endl;
if(x==gran){
v[ind].push_back(sum);
return;
}
rijesi(x+1, sum+a[x]);
rijesi(x+1, sum);
}
int main(){
scanf("%d%lld", &n, &m);
for(int i=0; i<n; i++){
scanf("%lld", a+i);
pref[i+1]=pref[i]+a[i];
}
gran=n/2;
ind=0;
rijesi(0, 0);
gran=n;
ind=1;
rijesi(n/2, 0);
sort(v[0].begin(), v[0].end());
sort(v[1].begin(), v[1].end());
int pos=0;
for(int i=v[0].size()-1; i>=0; i--){
while(pos<(int)v[1].size() && v[1][pos]<=m-v[0][i]){
pos++;
}
sol+=pos;
}
printf("%lld\n", sol);
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... |