# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259464 | MatheusLealV | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 721 ms | 25148 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>
using namespace std;
#define ll long long int
vector<ll> masks[2]; //eu vou ordenar o segundo bloco, e pra cada cara no 1o eu faço uma BB no 2o
ll resp = 0, m, arr[40];
int n, maxmask;
int mask_roll(int l, int r, bool div){
//calcular a mascara base
maxmask = (1LL << (r - l + 1));
for(int i = 0; i < maxmask; i++){
ll soma = 0, roll = i;
for(int j = l; j <= r; j++){
if(roll%2) soma += arr[j];
roll >>= 1;
}
masks[div].push_back(soma);
}
}
ll bb(ll num){
//return +1
ll val = - 1;
int ini = 0, fim = maxmask-1;
while(ini <= fim){
int mid = (ini+fim)/2;
if(masks[1][mid] + num <= m){
val = mid;
ini = mid+1;
}
else
fim = mid-1;
}
return val+1;
}
int main(){
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> arr[i];
int mid = n/2;
mask_roll(0, mid, 0);
mask_roll(mid+1, n-1, 1);
sort(masks[1].begin(), masks[1].end());
for(int i = 0; i < (int)masks[0].size(); i++){
resp += bb(masks[0][i]);
}
cout << resp << endl;
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... |