# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529744 | 2022-02-23T14:56:29 Z | c28dnv9q3 | Monster Game (JOI21_monster) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> template<typename F> int binsearch(int low, int high, F f) { if(f(low)) { return low; } while(high > low+1) { int m = (low + high) / 2; if(f(m)) { high = m; } else { low = m; } } return high; } int main() { int n; int m; std::cin >> n; std::cin >> m; std::vector<int> a(m); for(int i = 0; i < m; i++) { std::cin >> a[i]; } std::cout << binsearch(1, 1000000005, [&] (int x) { int j = 0; for(int i = 0; i < m; i++) { j += std::ceil((float)a[i]/x); } return j <= n; }); }