@@ -0,0 +1,1351 @@
+import java.io.*;%0A%0A//Beakjoon 1561 playground %0Apublic class Main %7B%0A%0A    public static int findAnswer() throws IOException %7B%0A        BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));%09%09%09%0A%09%09String%5B%5D l1 = br.readLine().split(%22 %22);%0A%09%09String%5B%5D l2 = br.readLine().split(%22 %22);%0A%0A%09%09long n = new Long(l1%5B0%5D);%0A%09%09int m = new Integer(l1%5B1%5D);%0A%09%09long%5B%5D time = new long%5Bm%5D;%0A%0A%09%09long max = 0;%0A%09%09for(int i = 0; i %3C m; i++) %7B%0A%09%09%09time%5Bi%5D = new Long(l2%5Bi%5D);%0A%09%09%09if (time%5Bi%5D %3E max) %7B%0A%09%09%09%09max = time%5Bi%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09if (n %3C= m) %7B%0A%09%09%09return (int) n;%0A%09%09%7D%0A%0A%09%09long minTime = 0;%0A%09%09long maxTime = n * max;%0A%0A%09%09long numPeople = 0;%0A%09%09while(minTime %3C maxTime) %7B%0A%09%09%09long currTime = (minTime + maxTime) / 2;%0A%09%09%09numPeople = m;%0A%09%09%09for (int i = 0; i %3C m; i++) %7B%0A%09%09%09%09numPeople += currTime / time%5Bi%5D;  %0A%09%09%09%7D%0A%09%09%09if (numPeople %3E= n) %7B%0A%09%09%09%09maxTime = currTime;%0A%09%09%09%7D else if (numPeople %3C n) %7B%0A%09%09%09%09minTime = currTime + 1;%0A%09%09%09%7D %0A%09%09%7D%09%0A%09    %0A%09    minTime--;%09    %0A%09%09numPeople = m;%0A%09%09for(int i = 0; i %3C m; i++) %7B%0A%09%09%09numPeople += minTime / time%5Bi%5D;%09%09%0A%09%09%7D%0A%09%09%0A%09    minTime++;%0A%09    for(int i = 0; i %3C m; i++) %7B%0A%09    %09if (minTime %25 time%5Bi%5D == 0) %7B%0A%09    %09%09numPeople++;%0A%09    %09%7D%0A%09    %09if (numPeople == n) %7B%0A%09    %09%09return i + 1;%0A%09    %09%7D%09%09%09%09%09%09%0A%09%09%7D%09%09%0A%09%09return -1;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) throws IOException %7B%09%09%0A%09%09long ans = findAnswer();%0A%09%09System.out.println(ans);%0A%09%7D%0A%0A%7D%0A

Solve Baekjoon 1561