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 <iostream>
#include "biscuits.h"
#include <vector>
#include <map>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const int K = 62;
long long count_tastiness(long long x, vector<long long> a) {
ll ans = 0;
map<ll, ll> dp0, dp1;
for (int i = 0; i < 69; i++)
a.push_back(0);
int k = a.size();
dp0[a[0]] = 1;
if (a[0] >= x) {
dp0[a[0] - x] = 1;
}
for (int i = 1; i < k; i++) {
for (pll jp : dp0) {
ll j = jp.first, val = jp.second;
dp1[j / 2 + a[i]] += val;
if (j / 2 + a[i] >= x) {
dp1[j / 2 + a[i] - x] += val;
}
}
/*for (pll jp : dp1) {
cout << i << " " << jp.first << " " << jp.second << endl;
}*/
dp0 = dp1;
dp1.clear();
}
for (pll jp : dp0) {
ans += jp.second;
}
return ans;
}
/*
2
3 2
2 1 2
3 3
5 2 1
*/
# | 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... |