# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
805045 | LittleCube | Counting Mushrooms (IOI20_mushrooms) | C++17 | 8 ms | 424 KiB |
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 "mushrooms.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int k = 100;
int count_mushrooms(int n)
{
vector<int> a, b;
int A = 0, B = 0;
a.emplace_back(0);
for (int i = 1; i < min(n, 2 * k); i++)
if (use_machine({0, i}))
b.push_back(i);
else
a.push_back(i);
if(n <= 2 * k)
return a.size();
if (a.size() >= k)
{
for (int i = 2 * k; i < n; i += k)
{
vector<int> q;
for (int j = 0; j < k && i + j < n; j++)
{
q.emplace_back(a[j]);
q.emplace_back(i + j);
}
B += (use_machine(q) + 1) / 2;
}
return n - (int)b.size() - B;
}
else
{
for (int i = 2 * k; i < n; i += k)
{
vector<int> q;
for (int j = 0; j < k && i + j < n; j++)
{
q.emplace_back(b[j]);
q.emplace_back(i + j);
}
A += (use_machine(q) + 1) / 2;
}
return a.size() + A;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |