Submission #1046585

#TimeUsernameProblemLanguageResultExecution timeMemory
1046585MarwenElarbiCounting Mushrooms (IOI20_mushrooms)C++17
56.64 / 100
6 ms444 KiB
#include <bits/stdc++.h> using namespace std; #include "mushrooms.h" #define pb push_back int count_mushrooms(int n) { int a=1; int b=0; vector<int> aa; aa.pb(0); vector<int> bb; for (int i = 1; i < min(n,200); i++) { int cur=use_machine({i,0}); (cur==1 ? bb : aa).pb(i); (cur==1 ? b : a)++; } int ans=a; for (int i = 200; i < n; i+=99) { vector<int> cur; int k=0; cur.pb((aa.size()>bb.size() ? aa[k++] : bb[k++])); for (int j = 0; j < min(n-i,99); ++j) { cur.pb(i+j); cur.pb((aa.size()>bb.size() ? aa[k++] : bb[k++])); } int cnt=use_machine(cur); ans+=(aa.size()<=bb.size() ? cnt/2 : cur.size()-k-cnt/2); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...