Skip to content

Commit 1efd8bd

Browse files
authored
Merge pull request #719 from AlgorithmWithGod/Ukj0ng
[20250822] BOJ / G3 / 하늘에서 별똥별이 빗발친다 / 한종욱
2 parents 9c95f3a + a9205ac commit 1efd8bd

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
private static int[][] stars;
9+
private static int N, M, L, K, answer;
10+
11+
public static void main(String[] args) throws IOException {
12+
init();
13+
14+
bw.write(answer + "\n");
15+
bw.flush();
16+
bw.close();
17+
br.close();
18+
}
19+
20+
private static void init() throws IOException {
21+
StringTokenizer st = new StringTokenizer(br.readLine());
22+
N = Integer.parseInt(st.nextToken());
23+
M = Integer.parseInt(st.nextToken());
24+
L = Integer.parseInt(st.nextToken());
25+
K = Integer.parseInt(st.nextToken());
26+
answer = K;
27+
int max = 0;
28+
29+
stars = new int[K][2];
30+
31+
Set<Integer> xCandidates = new HashSet<>();
32+
Set<Integer> yCandidates = new HashSet<>();
33+
34+
for (int i = 0; i < K; i++) {
35+
st = new StringTokenizer(br.readLine());
36+
stars[i][0] = Integer.parseInt(st.nextToken());
37+
stars[i][1] = Integer.parseInt(st.nextToken());
38+
xCandidates.add(stars[i][0]);
39+
yCandidates.add(stars[i][1]);
40+
}
41+
42+
for (int x : xCandidates) {
43+
for (int y : yCandidates) {
44+
int count = 0;
45+
46+
for (int i = 0; i < K; i++) {
47+
if (stars[i][0] >= x && stars[i][0] <= x + L &&
48+
stars[i][1] >= y && stars[i][1] <= y + L) {
49+
count++;
50+
}
51+
}
52+
53+
max = Math.max(max, count);
54+
}
55+
}
56+
57+
answer -= max;
58+
}
59+
}
60+
```

0 commit comments

Comments
 (0)