Submission #675763

#TimeUsernameProblemLanguageResultExecution timeMemory
675763VodkaInTheJarPacking Biscuits (IOI20_biscuits)C++14
0 / 100
25 ms1216 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define endl '\n' using namespace std; long long pr[62]; unordered_map <long long, long long> dp[62]; long long f(int pos, long long sm, long long x) { if (sm < 0) return 0; if (pos == -1 || sm == 0) return 1; sm = min(sm, (1ll << (pos + 1)) - 1); if (dp[pos].count(sm)) return dp[pos][sm]; long long ans = f(pos-1, sm, x); long long sm1 = min(sm - (1 << pos), (pr[pos] - (x << pos)) / x); ans += f(pos-1, sm1, x); return dp[pos][sm] = ans; } long long count_tastiness(long long x, vector <long long> a) { pr[0] = a[0]; for (int i = 1; i <= 61; i++) { pr[i] = pr[i-1]; if (i < (int)a.size()) pr[i] += (1ll << i) * a[i]; } long long last = 0; for (int i = 0; i <= 61; i++) if ((x << i) > pr[61]) { last = i-1; break; } for (int i = 0; i <= last; i++) dp[i].clear(); return f(last, (1ll << 61), x); } /* int main() { long long n, x; cin >> x >> n; vector <long long> v(n); for (int i = 0; i < n; i++) cin >> v[i]; cout << count_tastiness(x, v) << endl; } */
#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...