This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include <vector>
using namespace std;
//x = number of people (p)
//y = tastiness of each bag (i)
long long x;
void tle_assert(bool b)
{
if(!b) while(1);
}
long long solve(vector<int> B)
{
if(B.empty()) return 1;
//Case 1
long long ans1 = 1;
for(int i = 0; i < (int)B.size(); i++)
ans1 *= 2;
//Case 2
long long ans2;
int pos2 = -1;
for(int i = (int)B.size() - 1; i >= 0; i--)
if(B[i] == 2)
{
pos2 = i;
break;
}
if(pos2 == -1)
ans2 = 0;
else
{
B.resize(pos2);
ans2 = solve(B);
}
return ans1 + ans2;
}
long long count_tastiness(long long x1, vector<long long> a)
{
x = x1;
while((int)a.size() < 62) a.push_back(0);
int k = (int)a.size();
for(int i = 0; i+1 < k; i++)
{
if(a[i] >= x+1)
{
long long M = (a[i] - (x+1))/2;
a[i+1] += M;
a[i] -= 2*M;
}
else if(a[i] == x)
{
;
}
else
{
long long M = a[i]/2;
a[i+1] += M;
a[i] = 0;
}
}
vector<int> B;
long long res = 1;
for(int i = 0; i < k; i++)
{
if(a[i] == 0)
{
res *= solve(B);
B.clear();
}
else
B.push_back(a[i]);
}
return res;
}
# | 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... |