This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'
using namespace std;
long long count_tastiness(long long x, vector <long long> a) {
map <long long, int> mp;
mp[0]++;
int sz = (int)a.size();
for (int i = 0; ; i++) {
map <long long, int> new_mp;
long long to_add = (i < sz ? a[i] : 0);
for (auto j: mp)
new_mp[(j.first >> 1ll) + to_add] += j.second;
mp = new_mp;
bool is = false;
for (auto it = prev(new_mp.end()); it->first >= x; it--) {
is = true;
mp[it->first - x] += it->second;
if (it == new_mp.begin())
break;
}
if (!is && i >= sz)
break;
}
int ans = 0;
for (auto i: mp)
ans += i.second;
return ans;
}
/*
int main() {
long long x, n;
cin >> x >> n;
vector <long long> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
cout << count_tastiness(x, a) << endl;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |