Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Seol-JY/202511/27 BOJ G5 선발 명단.md‎
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
```java
import java.io.*;
import java.util.*;

public class Main {

static int N = 11;
static int[][] abilities;
static boolean[] visited;
static int maxAbility;

static void dfs(int position, int currentAbility) {
if (position == N) {
maxAbility = Math.max(maxAbility, currentAbility);
return;
}

for (int i = 0; i < N; i++) {
if (!visited[i] && abilities[i][position] > 0) {
visited[i] = true;
dfs(position + 1, currentAbility + abilities[i][position]);
visited[i] = false;
}
}
}

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());

for (int t = 0; t < T; t++) {
abilities = new int[N][N];
visited = new boolean[N];
maxAbility = 0;

for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < N; j++) {
abilities[i][j] = Integer.parseInt(st.nextToken());
}
}

dfs(0, 0);
System.out.println(maxAbility);
}
}
}

```