Skip to content

Commit 4b68bee

Browse files
authored
Merge pull request #1951 from AlgorithmWithGod/LiiNi-coder
[20260220] BOJ / G5 / 선발 명단 / 이인희
2 parents 2c2a4a5 + 4528515 commit 4b68bee

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.StringTokenizer;
6+
7+
public class Main {
8+
private static final int N = 11;
9+
private static int[][] Scores = new int[N][N];
10+
private static boolean[] Used = new boolean[N];
11+
private static int MaxSum = 0;
12+
13+
public static void main(String[] args) throws IOException {
14+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
15+
int t = Integer.parseInt(br.readLine());
16+
while(t-->0){
17+
for (int i = 0; i < N; i++) {
18+
StringTokenizer st = new StringTokenizer(br.readLine());
19+
for (int j = 0; j < N; j++) {
20+
Scores[i][j] = Integer.parseInt(st.nextToken());
21+
}
22+
}
23+
Used = new boolean[N];
24+
MaxSum = 0;
25+
dfs(0, 0);
26+
System.out.println(MaxSum);
27+
}
28+
}
29+
30+
private static void dfs(int pos, int currentSum) {
31+
if (pos == N) {
32+
if (currentSum > MaxSum) {
33+
MaxSum = currentSum;
34+
}
35+
return;
36+
}
37+
for (int player = 0; player < N; player++) {
38+
if(Scores[player][pos] == 0) continue;
39+
if (!Used[player]) {
40+
Used[player] = true;
41+
dfs(pos + 1, currentSum + Scores[player][pos]);
42+
Used[player] = false;
43+
}
44+
}
45+
}
46+
}
47+
48+
```

0 commit comments

Comments
 (0)