이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#ifdef NYAOWO
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;
const int MAXK = 60;
int a[MAXK + 10];
map<pii, int> mem;
int dp(int k, int cur, int x) {
cur /= 2;
if(k < MAXK) cur += a[k];
pii key(k, cur);
if(mem.count(key)) return mem[key];
if(k > MAXK && cur == 0) return mem[key] = 1;
return mem[key] = dp(k + 1, cur, x) + (cur < x ? 0 : dp(k + 1, cur - x, x));
}
// long long count_tastiness_2(long long x, std::vector<long long> _a) {
// memset(a, 0, sizeof(a));
// int k = sz(_a);
// int su = 0;
// For(i, 0, k - 1) {
// a[i] = _a[i];
// su += (1ll << i) * a[i];
// }
// int ans = 0;
// For(s, 0, su) {
// int cur = 0;
// bool fail = false;
// For(i, 0, 19) {
// cur = cur / 2 + a[i];
// if(s & (1 << i)) cur -= x;
// if(cur < 0) {
// fail = true;
// break;
// }
// }
// if(!fail) ans++;
// }
// return ans;
// }
long long count_tastiness(long long x, std::vector<long long> _a) {
memset(a, 0, sizeof(a));
mem.clear();
int k = sz(_a);
For(i, 0, k - 1) {
a[i] = _a[i];
}
// cerr << count_tastiness_2(1, _a) << "\n";
return dp(0, 0, x);
}
# | 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... |