Submission #805045

#TimeUsernameProblemLanguageResultExecution timeMemory
805045LittleCubeCounting Mushrooms (IOI20_mushrooms)C++17
56.93 / 100
8 ms424 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int k = 100; int count_mushrooms(int n) { vector<int> a, b; int A = 0, B = 0; a.emplace_back(0); for (int i = 1; i < min(n, 2 * k); i++) if (use_machine({0, i})) b.push_back(i); else a.push_back(i); if(n <= 2 * k) return a.size(); if (a.size() >= k) { for (int i = 2 * k; i < n; i += k) { vector<int> q; for (int j = 0; j < k && i + j < n; j++) { q.emplace_back(a[j]); q.emplace_back(i + j); } B += (use_machine(q) + 1) / 2; } return n - (int)b.size() - B; } else { for (int i = 2 * k; i < n; i += k) { vector<int> q; for (int j = 0; j < k && i + j < n; j++) { q.emplace_back(b[j]); q.emplace_back(i + j); } A += (use_machine(q) + 1) / 2; } return a.size() + A; } }
#Verdict Execution timeMemoryGrader output
Fetching results...