Submission #208175

#TimeUsernameProblemLanguageResultExecution timeMemory
208175fr_klrIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
6 ms632 KiB
//I wanna live before i die #include<bits/stdc++.h> using namespace std; const long long maxn = 500 + 5, inf = 1e16 + 69, V = 5, delta = 998244353; int n, m; map<int, int> w; vector<pair<int, int> > part; vector<int> v; int dp[maxn]; int find_first(int mask){ for(int i = 0;; i++) if((1 << i) & mask) return i; } void first_part(int sz){ for(int mask = 1; mask < (1 << sz); mask++){ int u = find_first(mask); if(__builtin_popcount(mask) == 1) dp[mask] = v[u]; else dp[mask] = dp[mask - (mask & -mask)] + v[u]; w[dp[mask]]++; } } int make_part_1(){ part.push_back(make_pair(0, 1)); int A = 1; for(auto e : w){ int f = e.first; int s = part[part.size() - 1].second + e.second; part.push_back(make_pair(f, s)); A = s; } return A; } int find_amount(int A){ if(A < 0) return 0; pair<int, int> p = {A, inf}; int e = upper_bound(part.begin(), part.end(), p) - part.begin(); return part[e - 1].second; } int second_part(int sz){ memset(dp, 0, sizeof dp); long long Ans = 0; for(int mask = 1; mask < (1 << (n - sz)); mask++){ int u = find_first(mask) + sz; if(__builtin_popcount(mask) == 1) dp[mask] = v[u]; else dp[mask] = dp[mask - (mask & -mask)] + v[u]; Ans += find_amount(m - dp[mask] - 1); } return Ans; } void input(){ cin >> n >> m; for(int i = 0; i < n; i++){ int tmp; cin >> tmp; v.push_back(tmp); } } void calc(){ first_part(n / 2); cout << (make_part_1() + second_part(n / 2)) << endl; } int main(){ ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); input(); calc(); }
#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...