# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420699 | ioi | Counting Mushrooms (IOI20_mushrooms) | C++14 | 15 ms | 332 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) {
int ans = 1 ;
if (n <= 200){
for(int i = 1 ; i < n ; i ++)
ans += !use_machine({0 , i});
return ans ;
}
vector<int> A , B ;
A .push_back(0);
for(int i = 1 ; i <= 300 ; i ++){
if(!use_machine({0 , i}))A.push_back(i) , ans ++ ;
else B.push_back(i);
}
if(A.size() > B.size()){
int p = 301 ;
while(p < n){
vector<int> tocheck ;
tocheck.push_back(0);
int curr = 0 ;
for(int i = 1 ; i < A.size() && p < n ; i ++){
tocheck.push_back(p++);
tocheck.push_back(A[i]);
curr ++ ;
}
int c = use_machine(tocheck);
ans += (curr - c / 2);
}
}
else {
int p = 301 ;
while(p < n){
vector<int> tocheck ;
tocheck.push_back(B[0]);
int curr = 0 ;
for(int i = 1 ; i < B.size() && p < n ; i ++){
tocheck.push_back(p++);
tocheck.push_back(B[i]);
curr ++ ;
}
int c = use_machine(tocheck);
ans += c / 2;
}
}
return ans ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |