# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828308 | tomruk | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 312 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;
int count_mushrooms(int n) {
vector<int> a = {0},b;
int last = 1;
int th = 0;
int val = 1e9;
for(int i = 1;i<n;i++){
if(2 * i - 2 + (n + i - 1)/i < val){
th = i;
val = 2 * i - 2 + (n + i - 1)/i;
}
}
while(last < n && max(a.size(),b.size()) < th){
int num = use_machine({0,last});
if(num == 0)
a.push_back(last);
else b.push_back(last);
last++;
}
int ca = 0,cb = 0;
while(last < n){
if(a.size() > b.size()){
int cnt = 0;
vector<int> ask;
while(cnt < a.size() && last < n){
ask.push_back(last);
ask.push_back(a[cnt]);
cnt++;
last++;
}
int num = use_machine(ask);
ca += cnt;
ca -= num/2;
ca -= num&1;
}
else{
int cnt = 0;
vector<int> ask;
while(cnt < b.size() && last < n){
ask.push_back(last);
ask.push_back(b[cnt]);
cnt++;
last++;
}
int num = use_machine(ask);
ca += num/2;
ca += num&1;
}
}
return a.size() + ca;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |