Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- using namespace std;
- typedef long long ll;
- int main() {
- ll n, k;
- cin >> n >> k;
- ll niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- ll L = 0, R = 1e18;
- ll res = 1e18;
- while(L <= R) {
- ll middle = (L + R) / 2;
- ll kolku_zadaci = 0;
- for(int i = 0; i < n; i++) {
- kolku_zadaci += middle / niza[i];
- }
- if(kolku_zadaci >= k) {
- res = min(res, middle);
- R = middle - 1;
- }
- else {
- L = middle + 1;
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement