Submission #66064

#TimeUsernameProblemLanguageResultExecution timeMemory
66064bazsi700Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
888 ms9180 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long //14:20 int n; ll m; ll c[45]; ll way[2150000]; unordered_map<ll,int> compr; vector<ll> did; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) { cin >> c[i]; } if(n <= 22) { ll ways = 0; for(int mask = 0; mask < (1<<n); mask++) { ll money = m; for(int i = 0; i < n; i++) { if(mask&(1<<i)) { money-= c[i]; } } if(money >= 0) { ways++; } } cout << ways; } else { ll ways = 0; int b1 = 19; for(int mask = 0; mask < (1<<b1); mask++) { ll money = m; for(int i = 0; i < b1; i++) { if(mask&(1<<i)) { money-= c[i]; } } if(money >= 0) { did.push_back(m-money); } } sort(did.begin(),did.end()); int in = 0; ll prev = -1; for(ll el : did) { way[in++]++; prev = el; } for(int i = 0; i <= in; i++) { way[i]+=way[i-1]; } for(int mask = 0; mask < (1<<(n-b1)); mask++) { ll money = m; for(int i = b1; i < n; i++) { if(mask&(1<<(i-b1))) { money-= c[i]; } } if(money >= 0) { auto it = upper_bound(did.begin(),did.end(),money); if(it != did.begin()) { ways+= way[it-did.begin()-1]; } } } cout << ways; } return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:51:12: warning: variable 'prev' set but not used [-Wunused-but-set-variable]
         ll prev = -1;
            ^~~~
#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...