Submission #208179

#TimeUsernameProblemLanguageResultExecution timeMemory
208179fr_klrIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
1089 ms90820 KiB
//I wanna live before i die #include<bits/stdc++.h> using namespace std; const long long maxn = (1 << 20) + 20, inf = 1e19 + 69, V = 5, delta = 998244353; long long n, m; map<long long, long long> w; vector<pair<long long, long long> > part; vector<long long> v; long long dp[maxn]; long long find_first(long long mask){ for(long long i = 0;; i++) if((1 << i) & mask) return i; } void first_part(long long sz){ for(long long mask = 1; mask < (1 << sz); mask++){ long long 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]]++; } } long long make_part_1(){ part.push_back(make_pair(0, 1)); long long A = 1; for(auto e : w){ long long f = e.first; long long s = part[part.size() - 1].second + e.second; part.push_back(make_pair(f, s)); A = s; } return A; } long long find_amount(long long A){ if(A < 0) return 0; pair<long long, long long> p = {A, inf}; long long e = upper_bound(part.begin(), part.end(), p) - part.begin(); return part[e - 1].second; } long long second_part(long long sz){ memset(dp, 0, sizeof dp); long long Ans = 0; for(long long mask = 1; mask < (1 << (n - sz)); mask++){ long long 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(long long i = 0; i < n; i++){ long long 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(); }

Compilation message (stderr)

bobek.cpp:5:51: warning: overflow in implicit constant conversion [-Woverflow]
 const long long maxn = (1 << 20) + 20, inf = 1e19 + 69, V = 5, delta = 998244353;
                                              ~~~~~^~~~
#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...