Submission #72411

#TimeUsernameProblemLanguageResultExecution timeMemory
72411someone_aaIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
571 ms21500 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 42; vector<ll>suma, sumb; ll arr[maxn], n, fn, sn; ll budget; void get_f() { for(int i=0;i<(1<<fn);i++) { ll sum = 0LL; for(int j=0;j<fn;j++) { if(i&(1<<j)) { sum += arr[j]; } } suma.pb(sum); } sort(suma.begin(), suma.end()); } void get_s() { for(int i=0;i<(1<<sn);i++) { ll sum = 0LL; for(int j=0;j<sn;j++) { if(i&(1<<j)) { sum += arr[j+fn]; } } sumb.pb(sum); } sort(sumb.begin(), sumb.end()); } void solve() { ll result = 0LL; for(int i=0;i<suma.size();i++) { if(suma[i] > budget) continue; else { int ind = 0; for(int cekor = sumb.size()/2;cekor>0;cekor/=2) { while(ind + cekor < sumb.size() && sumb[ind+cekor]<=(budget-suma[i])) ind += cekor; } result += 1LL * (ind+1); } } cout<<result; } int main() { cin>>n>>budget; for(int i=0;i<n;i++) { cin>>arr[i]; } fn = n / 2; sn = n - fn; get_f(); get_s(); solve(); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<suma.size();i++) {
                 ~^~~~~~~~~~~~
bobek.cpp:44:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while(ind + cekor < sumb.size() && sumb[ind+cekor]<=(budget-suma[i])) ind += cekor;
                       ~~~~~~~~~~~~^~~~~~~~~~~~~
#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...