# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315643 | Sorting | Counting Mushrooms (IOI20_mushrooms) | C++17 | 3 ms | 256 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>
using namespace std;
const int C = 200;
int count_mushrooms(int n){
int cnt = 1;
vector<int> a{0}, b;
for(int i = 1; i < min(n, C + 1); ++i){
if(!use_machine(vector<int>{0, i})){
cnt++;
a.push_back(i);
}
else b.push_back(i);
}
for(int i = min(n, C); i < n; i += (C / 2)){
vector<int> v;
int x = min(C / 2, n - i);
if(a.size() > b.size()){
for(int j = 0; j < x; ++j){
v.push_back(a[j]);
v.push_back(i + j);
}
v.push_back(a[x]);
}
else{
for(int j = 0; j < x; ++j){
v.push_back(b[j]);
v.push_back(i + j);
}
v.push_back(b[x]);
}
int t = use_machine(v);
if(a.size() > b.size()) cnt += x - t / 2;
else cnt += t / 2;
}
return cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |