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 = 1;
- long long R = 40000000000000;
- long long result = 40000000000000;
- while(L <= R) {
- long long middle = (L + R) / 2;
- long long resheni_zadaci = 0;
- for(int i = 0; i < n; i++) {
- resheni_zadaci += (middle / niza[i]);
- }
- if(resheni_zadaci >= K) {
- R = middle - 1;
- result = min(result, middle);
- }
- else {
- L = middle + 1;
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement