From e46e44b0174c660a36c84ef956e0127920cd8038 Mon Sep 17 00:00:00 2001 From: heeheejj Date: Sun, 3 Dec 2023 01:37:12 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Week28=20PRG=20121684=20=EC=B2=B4=EC=9C=A1?= =?UTF-8?q?=EB=8C=80=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\354\234\241\353\214\200\355\232\214.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" diff --git "a/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" "b/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" new file mode 100644 index 0000000..488e174 --- /dev/null +++ "b/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" @@ -0,0 +1,33 @@ +# PCCP 모의고사 1 1번 외톨이 알파벳 +# dfs + 백트래킹 + +def solution(ability): + answer = 0 + new = [] + N = len(ability) # 학생수 + M = len(ability[0]) # 종목 개수 + + for j in range(M): + arr = [] + for i in range(N): + arr.append((ability[i][j], i)) + arr.sort(key = lambda x:-x[0]) + new.append(arr) + visited = [False]*N + + def dfs(i, a_sum): + if i == M: + nonlocal answer + answer = max(answer, a_sum) + return + + for j in range(N): + a, idx = new[i][j] + if not visited[idx]: + visited[idx] = True + dfs(i+1, a_sum + a) + visited[idx] = False + + dfs(0, 0) + + return answer \ No newline at end of file From 4fae17b55e92bfb65bd39041cd240e932756807c Mon Sep 17 00:00:00 2001 From: heeheejj Date: Sun, 3 Dec 2023 01:38:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Week28=20PRG=20121684=20=EC=B2=B4=EC=9C=A1?= =?UTF-8?q?=EB=8C=80=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" "b/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" index 488e174..adbfc9f 100644 --- "a/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" +++ "b/heeheej/week28/PRG_121684_\354\262\264\354\234\241\353\214\200\355\232\214.py" @@ -1,4 +1,4 @@ -# PCCP 모의고사 1 1번 외톨이 알파벳 +# PCCP 모의고사 1 2번 체육대회 # dfs + 백트래킹 def solution(ability):