#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
const int LIM = 142;
int count_mushrooms(int n)
{
vector<int> v[2];
v[0].push_back(0);
int ult=0;
for(int i=1;i<n;i++)
{
v[0].push_back(i);
if(use_machine(v[0])==0)
{
}
else
{
v[0].pop_back();
v[1].push_back(i);
}
ult = i;
//if(max(v[0].size(), v[1].size()) >= LIM) break;
if(v[0].size() >= LIM) break;
}
if(ult==n-1)
return v[0].size();
int cnt = v[0].size();
if(v[0].size() >= LIM)
{
for(int i=ult+1;i<n;i+=v[0].size())
{
vector<int> newv;
for(int j=0;j<v[0].size();j++)
{
newv.push_back(v[0][j]);
if(i+j < n) newv.push_back(i+j);
}
int x = (int)newv.size() - 1 - use_machine(newv);
cnt += (x+1)/2;
}
}
else
{
assert(0);
assert(v[1].size() >= LIM);
}
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |