From 38413e81bbf84d27288cbe8642dae6bc44961c4f Mon Sep 17 00:00:00 2001 From: ash-hun Date: Sun, 4 Jun 2023 19:58:13 +0900 Subject: [PATCH 1/2] complet G4 Exploding String --- ...220\354\227\264 \355\217\255\353\260\234.py" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "230605 BOJ G4 \353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234/\353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234.py" diff --git "a/230605 BOJ G4 \353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234/\353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234.py" "b/230605 BOJ G4 \353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234/\353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234.py" new file mode 100644 index 0000000..d4e4757 --- /dev/null +++ "b/230605 BOJ G4 \353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234/\353\254\270\354\236\220\354\227\264 \355\217\255\353\260\234.py" @@ -0,0 +1,17 @@ +def solution(s, bomb): + # s = str(input()) + # bomb = str(input()) + + stack = [] + for elem in s: + stack.append(elem) + if "".join(stack[-len(bomb):])== bomb: + for _ in range(len(bomb)): + stack.pop() + if stack: + print(''.join(stack)) + else: + print('FRULA') + +print(solution("mirkovC4nizCC44", "C4")) #mirkovniz +print(solution("12ab112ab2ab", "12ab")) #FRULA \ No newline at end of file From 606640b943e601c95cebda346ccd875cfee160cc Mon Sep 17 00:00:00 2001 From: Choi JaeHoon Date: Tue, 20 Jun 2023 02:25:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Complete=20Boj=20G4=20=ED=8C=B0=EB=A6=B0?= =?UTF-8?q?=EB=93=9C=EB=A1=AC=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\241\254_\354\236\254\355\233\210.py" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "230614 BOJ G4 \355\214\260\353\246\260\353\223\234\353\241\254/\355\214\260\353\246\260\353\223\234\353\241\254_\354\236\254\355\233\210.py" diff --git "a/230614 BOJ G4 \355\214\260\353\246\260\353\223\234\353\241\254/\355\214\260\353\246\260\353\223\234\353\241\254_\354\236\254\355\233\210.py" "b/230614 BOJ G4 \355\214\260\353\246\260\353\223\234\353\241\254/\355\214\260\353\246\260\353\223\234\353\241\254_\354\236\254\355\233\210.py" new file mode 100644 index 0000000..9113cfa --- /dev/null +++ "b/230614 BOJ G4 \355\214\260\353\246\260\353\223\234\353\241\254/\355\214\260\353\246\260\353\223\234\353\241\254_\354\236\254\355\233\210.py" @@ -0,0 +1,26 @@ +# 백준 사이트는 python과 pypy3가 있는데 혹시 알고리즘이 틀리지 않은것 같다면 둘다 시도해보자... + + +import sys +input = sys.stdin.readline + +N, M = map(int,input().split()) +info = [list(map(int,input().split())) for _ in range(M)] +dp = [ [0 for _ in range(N)] for _ in range(M)] + +for i in range(M): + dp[i][0] = info[i][0] + +for day in range(1,N): + for dessert in range(M): + for i in range(M): + if i == dessert: + dp[dessert][day] = max(dp[dessert][day], info[dessert][day]//2 + dp[i][day-1]) + else: + dp[dessert][day] = max(dp[dessert][day], info[dessert][day] + dp[i][day-1]) + +result = 0 +for i in range(M): + result = max(result,dp[i][-1]) + +print(result) \ No newline at end of file