이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;
#define ST first
#define ND second
#define PB push_back
map<pair<int, ll>, ll>dp;
vector<ll>A;
ll X;
ll rec(int a, ll add) {
if(dp.find({a,add}) != dp.end()) return dp[{a,add}];
ll cur = A[a] + add;
if(a >= 63) return 1;
ll ans = 0;
if(cur >= X) {
cur -= X;
if(dp.find({a + 1, cur/2}) != dp.end()) ans+=dp[{a+1,cur/2}];
else ans += rec(a + 1, cur / 2);
cur += X;
}
if(dp.find({a+1,cur/2}) != dp.end()) ans += dp[{a+1, cur/2}];
else ans += rec(a + 1, cur/2);
return ans;
}
ll count_tastiness(ll x, vector<ll>a) {
A.resize(64);
for(int i = 0; i < (int)a.size(); ++i) A[i] = a[i];
X = x;
dp.clear();
return rec(0, 0);
}
//int main() {
// cout << count_tastiness(2,{2,1,2});
//}
# | 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... |