이 제출은 이전 버전의 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;
struct PairHash {
int operator()(const pii &p) const {
return p.S * MAXK + p.F;
}
};
int a[MAXK + 10];
unordered_map<pii, int, PairHash> 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) return mem[key] = cur + 1;
return mem[key] = dp(k + 1, cur, x) + (cur < x ? 0 : dp(k + 1, cur - x, x));
}
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... |