Advertisement
vov44k

t672

Dec 9th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class t672 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.  
  8.         int n, k;
  9.         n = in.nextInt();
  10.         k = in.nextInt();
  11.         int[] a = new int[n];
  12.         for (int i = 0; i < n; i++)
  13.             a[i] = in.nextInt();
  14.  
  15.         int l = 0, r = 10000001;
  16.  
  17.         while (r - l > 1) {
  18.             int m = (l + r) / 2;
  19.             if (m == 0){
  20.                 System.out.println(0);
  21.                 return;
  22.             }
  23.             int now = 0;
  24.             for (int i = 0; i < n; i++)
  25.                 now += a[i] / m;
  26.             if (now >= k)
  27.                 l = m;
  28.             else
  29.                 r = m;
  30.         }
  31.         System.out.println(l);
  32.         in.close();
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement