이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;
ll P[67];
map<pair<int,ll>,ll>mem;
map<pair<int,ll>,bool>was;
ll f(int i,ll x)
{
x=min(x,(1LL<<(i+1))-1);
if(i==0) return x+1;
if(was[{i,x}]) return mem[{i,x}];
ll ans=0;
if(x&(1LL<<i)) ans=f(i-1,P[i-1])+f(i-1,min(P[i-1],x-(1LL<<i)));
else ans=f(i-1,min(x,P[i-1]));
was[{i,x}]=1;
return mem[{i,x}]=ans;
}
ll count_tastiness(ll x, vector<ll>w)
{
int k=sz(w);
P[0]=w[0];
for(int i=1;i<60;i++)
{
P[i]=P[i-1];
if(i<k) P[i]+=w[i]*(1LL<<i);
}
for(int i=0;i<60;i++) P[i]/=x;
was.clear();
return f(59,P[59]);
}
# | 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... |