이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
int sz(const T &a){return int(a.size());}
const int MAXN=62;
map<ll,ll> dp[MAXN];
ll am[MAXN];
ll maxam[MAXN];
ll x;
ll solve(int loc, ll wanted){
if(wanted>maxam[loc])return 0;
if(loc==0){
ll ans=0;
if(am[loc]>=wanted)ans++;
if(am[loc]-x>=wanted)ans++;
return ans;
}
if(dp[loc].count(wanted))return dp[loc][wanted];
return dp[loc][wanted]=solve(loc-1,ll(2)*max(ll(0),wanted-am[loc]))+solve(loc-1,ll(2)*max(ll(0),wanted+x-am[loc]));
}
ll count_tastiness(ll X, vector<ll> a){//maytlenotsure
x=X;
int n=sz(a);
for(int i=0;i<=60;i++){
dp[i]=map<ll,ll>();
if(i<n)am[i]=a[i];
else am[i]=0;
}
maxam[0]=am[0];
for(int i=1;i<=60;i++){
maxam[i]=maxam[i-1]/2+am[i];
}
return solve(60,0);
}
# | 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... |