이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "biscuits.h"
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9 + 7, INF = 1e18;
ll mod(ll x, ll m = MOD) {return (x + m) % m;}
int n;
ll x, tot = 0ll;
vll A;
bool check(ll s)
{
vll B = A;
for(int i =0; i < x; i++)
{
ll cur = s;
for(int j = n - 1; j >= 0; j--)
{
ll q = min(B[j], cur/(1 << j));
cur -= q * (1 << j);
B[j] -= q;
}
if(cur > 0)
return false;
}
return true;
}
ll sub1()
{
int ans = 0;
for(int i =0; i <= tot/x; i++)
{
if(i == 0 || check(i))
ans++;
}
return ans;
}
map<ll,ll> dp[100];
ll f(int i, ll sum)
{
if(i == n - 1)
return 1ll;
if(dp[i].find(sum) != dp[i].end())
return dp[i][sum];
if(sum > 0)
return dp[i][sum] = f(i + 1, sum/2ll + A[i + 1]) + f(i + 1, (sum - 1)/2ll + A[i + 1]);
else
return dp[i][sum] = f(i + 1, A[i + 1]);
}
ll count_tastiness(ll X, vll a)
{
x = X;
A = a;
n = (int)(a.size());
while(n < 100)
{
A.pb(0ll);
n++;
}
return f(0, a[0]);
}
/*
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cout << count_tastiness(1, {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... |