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>
#include "biscuits.h"
using namespace std;
const int MAX_N = 1e5 + 5;
int K;
long long X, ans;
bool dp[2][MAX_N];
long long count_tastiness(long long x, vector <long long> a) {
ans = 0;
for(int i = 0; i <= 100000; i++) {
dp[0][i] = dp[1][i] = false;
}
X = x, K = a.size();
dp[1][0] = true;
for(int i = 0; i < K; i++) {
int now = i % 2, pre = now ^ 1;
for(int j = a[i]; j >= 0; j--) {
for(int k = 100000; k >= (1ll<<i) * j; k--) {
dp[now][k] |= dp[pre][k - (1ll<<i) * j];
}
}
}
for(int i = 0; i <= 100000; i += x) {
ans += dp[(K - 1) % 2][i];
}
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... |