Submission #74554

#TimeUsernameProblemLanguageResultExecution timeMemory
74554Adhyyan1252Ice Hockey World Championship (CEOI15_bobek)C++11
100 / 100
357 ms33816 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n, m; vector<ll> a, b, c; void brute(int i, int e, ll cost){ if(i == e+1){ b.push_back(cost); return; } brute(i+1, e, cost + a[i]); brute(i+1, e, cost); } int main(){ cin>>n>>m; a.resize(n); for(int i = 0; i < n; i++){ cin>>a[i]; } b.reserve(1000000); c.reserve(1000000); brute(0, n/2, 0); c = b; b.clear(); brute(n/2+1, n-1, 0); ll ans =0 ; sort(b.begin(), b.end()); sort(c.begin(), c.end()); int pntr = c.size() - 1; for(int i = 0; i < b.size(); i++){ while(pntr >= 0 && c[pntr] + b[i] > m){ pntr--; } ans += pntr + 1; } cout<<ans<<endl; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < b.size(); i++){
                 ~~^~~~~~~~~~
#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...