SHARE
TWEET

Untitled

a guest Oct 15th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int n, k;
  7. long long a[10500];
  8.  
  9. bool check(long long m) {
  10.     int ans = 0;
  11.  
  12.     for (int i = 0; i < n; ++i) {
  13.         ans += a[i] / m;
  14.     }
  15.  
  16.     return ans >= k;
  17. }
  18.  
  19. int main()
  20. {
  21.  
  22.     cin >> n >> k;
  23.  
  24.     for (int i = 0; i < n; ++i) {
  25.         cin >> a[i];
  26.     }
  27.  
  28.     long long left = 0, right = 100000000;
  29.  
  30.     while (left < right - 1) {
  31.         long long m = (left + right) / 2;
  32.         if (check(m)) {
  33.             left = m;
  34.         }
  35.         else {
  36.             right = m;
  37.         }
  38.     }
  39.  
  40.     cout << left;
  41.  
  42.     return 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top