Submission #259464

#TimeUsernameProblemLanguageResultExecution timeMemory
259464MatheusLealVIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
721 ms25148 KiB
#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)

bobek.cpp: In function 'int mask_roll(int, int, bool)':
bobek.cpp:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...