# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613685 | Jarif_Rahman | Counting Mushrooms (IOI20_mushrooms) | C++17 | 1057 ms | 408 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 k = sqrt(n);
k = max(2, k);
if(n > 10){
int mn = 1e9;
for(int i = 3; i <= n; i++){
int c = 0;
for(int j = i; j <= 2*i-1; j++) c = max(c, j-1+(n-j+i-1)/i);
if(c < mn) mn = c, k = i;
}
}
int ls = n;
for(int i = 1; i < n; i++){
if(max(A.size(), B.size()) == k){
ls = i;
break;
}
if(use_machine({0, i})) B.pb(i);
else A.pb(i);
}
int ans = A.size();
if(A.size() == k){
for(int i = ls; i < n; i+=k){
vector<int> Q;
for(int j = 0; j < k; j++){
Q.pb(A[j]);
if(i+j < min(n, i+k)) Q.pb(i+j);
}
int x = use_machine(Q);
ans+=min(n, i+k)-i-x%2-x/2;
}
}
else{
for(int i = ls; i < n; i+=k){
vector<int> Q;
for(int j = 0; j < k; j++){
Q.pb(B[j]);
if(i+j < min(n, i+k)) Q.pb(i+j);
}
int x = use_machine(Q);
ans+=x%2+x/2;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |