From f70aaf938a1fa3080fac864ddf69ce4f1f49642b Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Fri, 28 Nov 2025 23:14:21 +0900 Subject: [PATCH] =?UTF-8?q?[20251128]=20BOJ=20/=20G5=20/=20=EC=84=A0?= =?UTF-8?q?=EB=B0=9C=20=EB=AA=85=EB=8B=A8=20/=20=EC=84=A4=EC=A7=84?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \353\252\205\353\213\250.md\342\200\216" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "Seol-JY/202511/27 BOJ G5 \354\204\240\353\260\234 \353\252\205\353\213\250.md\342\200\216" diff --git "a/Seol-JY/202511/27 BOJ G5 \354\204\240\353\260\234 \353\252\205\353\213\250.md\342\200\216" "b/Seol-JY/202511/27 BOJ G5 \354\204\240\353\260\234 \353\252\205\353\213\250.md\342\200\216" new file mode 100644 index 00000000..ba509242 --- /dev/null +++ "b/Seol-JY/202511/27 BOJ G5 \354\204\240\353\260\234 \353\252\205\353\213\250.md\342\200\216" @@ -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); + } + } +} + +```