Skip to content

Commit 06c3785

Browse files
authored
Merge pull request #913 from AlgorithmWithGod/0224LJH
[20250917] BOJ / P4 / 옥토끼는 통신교육을 풀어라!! / 이종환
2 parents 224319c + 9ad4073 commit 06c3785

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.*;
6+
7+
public class Main {
8+
9+
static int problemCnt;
10+
static Long ans;
11+
static long [] arr;
12+
13+
public static void main(String[] args) throws NumberFormatException, IOException {
14+
init();
15+
process();
16+
print();
17+
}
18+
19+
public static void init() throws NumberFormatException, IOException {
20+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
21+
problemCnt = Integer.parseInt(br.readLine());
22+
StringTokenizer st = new StringTokenizer(br.readLine());
23+
ans = 1000_000_0000L;
24+
arr = new long[problemCnt];
25+
for (int i = 0; i < problemCnt; i++) {
26+
arr[i] = Long.parseLong(st.nextToken());
27+
}
28+
29+
30+
31+
}
32+
33+
public static void process() {
34+
Long st = 1L;
35+
Long end = 1000_000_001L;
36+
Long mid = (st+end)/2;
37+
38+
while(st < end) {
39+
boolean result = test(mid);
40+
41+
if (result) {
42+
ans = Math.min(ans, mid);
43+
end = mid;
44+
} else st = mid+1;
45+
46+
mid = (st+end)/2;
47+
48+
}
49+
}
50+
51+
52+
private static boolean test(Long diff) {
53+
long cnt = 0;
54+
55+
for (int i = 0; i < problemCnt; i++) {
56+
long result = arr[i]/diff;
57+
if (arr[i]%diff ==0) result--;
58+
cnt += result;
59+
}
60+
61+
if (cnt >= problemCnt) return false;
62+
63+
64+
return true;
65+
}
66+
67+
public static void print() {
68+
System.out.println(ans);
69+
}
70+
}
71+
```

0 commit comments

Comments
 (0)