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