Submission #1121505

#TimeUsernameProblemLanguageResultExecution timeMemory
1121505vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
40 / 100
1057 ms44520 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int min(int a,int b){ return (a < b ? a : b); } int max(int a,int b){ return (a > b ? a : b); } signed main(){ int n,m; cin >> n >> m; vector<int> sira(n); for(auto &i : sira)cin >> i; unordered_map<int,int> mp; int fsst = min(20,n); for(int mask=0;mask<(1 << fsst);++mask){ int curr = 0; for(int i=0;i<fsst;++i){ if(mask & (1 << i))curr += sira[i]; } if(curr > m)continue; else mp[curr]++; } fsst = n - 20; int cvb=0; fsst = max(fsst,0); for(int mask=0;mask < (1 << fsst);++mask){ int curr = 0; for(int i=20;i<n;++i){ if(mask & (1 << (i - 20)))curr +=sira[i]; } if(curr > m)continue; else{ for(auto &i : mp){ if(i.first > m - curr)break; cvb += i.second; } } } cout << cvb; }
#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...