Submission #1052307

#TimeUsernameProblemLanguageResultExecution timeMemory
1052307aykhnCounting Mushrooms (IOI20_mushrooms)C++17
56.78 / 100
6 ms596 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int B = 100; int count_mushrooms(int n) { vector<int> v[2]; v[0] = {0}; int i = 1; for (; i < n && max(v[0].size(), v[1].size()) < B + 1; i++) v[use_machine({0, i})].push_back(i); int res = 0; for (int j = i; j < n; j += B) { vector<int> q; int sz = min(n, j + B) - j; for (int k = j; k < min(n, j + B); k++) { if (v[0].size() > v[1].size()) { q.push_back(v[0][k - j]); q.push_back(k); } else { q.push_back(v[1][k - j]); q.push_back(k); } } if (v[0].size() > v[1].size()) { q.push_back(v[0].back()); res += sz - (use_machine(q) / 2); } else { q.push_back(v[1].back()); res += use_machine(q) / 2; } } return res + v[0].size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...