Advertisement
Josif_tepe

Untitled

Oct 28th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7. int main() {
  8.     ll n, k;
  9.     cin >> n >> k;
  10.    
  11.     ll niza[n];
  12.     for(int i = 0; i < n; i++) {
  13.         cin >> niza[i];
  14.     }
  15.     ll L = 0, R = 1e18;
  16.     ll res = 1e18;
  17.     while(L <= R) {
  18.         ll middle = (L + R) / 2;
  19.         ll kolku_zadaci = 0;
  20.        
  21.         for(int i = 0; i < n; i++) {
  22.             kolku_zadaci += middle / niza[i];
  23.         }
  24.         if(kolku_zadaci >= k) {
  25.             res = min(res, middle);
  26.             R = middle - 1;
  27.         }
  28.         else {
  29.             L = middle + 1;
  30.         }
  31.     }
  32.     cout << res << endl;
  33.    
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement