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>
using namespace std;
using LL = long long;
using pLL = array <LL, 2>;
LL count_tastiness(LL x, vector<LL> A) {
A.resize(61);
LL ans = 0;
vector <pLL> dp, ndp, ndp1, ndp2; // {j, dp[i][j]}
dp.push_back({A[0], 1});
for (LL i = 0; i < 60; i++){
for (pLL elm : dp){
LL j = elm[0], val = elm[1];
if (j >= x) ndp1.push_back({A[i + 1] + (j - x) / 2, val});
ndp2.push_back({A[i + 1] + j / 2, val});
}
dp.clear();
merge(ndp1.begin(), ndp1.end(), ndp2.begin(), ndp2.end(), back_inserter(ndp));
for (pLL elm : ndp){
if (dp.empty() || dp.back()[0] != elm[0]) dp.push_back(elm);
else dp.back()[1] += elm[1];
}
ndp.clear();
ndp1.clear();
ndp2.clear();
}
for (pLL elm : dp) ans += elm[1];
return ans;
}
# | 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... |