# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613631 | Jarif_Rahman | Counting Mushrooms (IOI20_mushrooms) | C++17 | 11 ms | 336 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 pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int count_mushrooms(int n){
vector<int> A, B;
A.pb(0);
int sq = sqrt(n);
sq = max(2, sq);
int ls = n;
for(int i = 1; i < n; i++){
if(max(A.size(), B.size()) == sq){
ls = i;
break;
}
if(use_machine({0, i})) B.pb(i);
else A.pb(i);
}
sq--;
int ans = A.size();
if(A.size() == sq+1){
for(int i = ls; i < n; i+=sq){
vector<int> Q;
for(int j = 0; j < sq; j++){
Q.pb(A[j]);
if(i+j < min(n, i+sq)) Q.pb(i+j);
}
Q.pb(A.back());
ans+=min(n, i+sq)-i-use_machine(Q)/2;
}
}
else{
for(int i = ls; i < n; i+=sq){
vector<int> Q;
for(int j = 0; j < sq; j++){
Q.pb(B[j]);
if(i+j < min(n, i+sq)) Q.pb(i+j);
}
Q.pb(B.back());
ans+=use_machine(Q)/2;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |