From 08a305a8f308c86a2f43e707edd6634ca02e75b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Tue, 30 Jan 2024 03:12:40 +0900 Subject: [PATCH 01/14] =?UTF-8?q?2024-01-30=20=ED=95=98=EC=9D=B4=ED=8D=BC?= =?UTF-8?q?=20=ED=86=A0=EB=A7=88=ED=86=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Munbin-Lee/README.md | 1 + ...4 \355\206\240\353\247\210\355\206\240.py" | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 "Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/32-\355\225\230\354\235\264\355\215\274 \355\206\240\353\247\210\355\206\240.py" diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index 46344715..1d4de17b 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -30,4 +30,5 @@ | 27차시 | 2024.01.13 | 다익스트라 | 군대탈출하기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/106 | | 28차시 | 2024.01.16 | 그래프 | 도넛과 막대 그래프 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/109 | | 29차시 | 2024.01.19 | 유니온파인드 | 거짓말 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/114 | +| 32차시 | 2024.01.30 | 백트래킹 | 하이퍼 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 | --- diff --git "a/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/32-\355\225\230\354\235\264\355\215\274 \355\206\240\353\247\210\355\206\240.py" "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/32-\355\225\230\354\235\264\355\215\274 \355\206\240\353\247\210\355\206\240.py" new file mode 100644 index 00000000..bfbc4839 --- /dev/null +++ "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/32-\355\225\230\354\235\264\355\215\274 \355\206\240\353\247\210\355\206\240.py" @@ -0,0 +1,71 @@ +from math import prod +from collections import deque + +stdin = open(0) +sizes = list(map(int, stdin.readline().split())) +totalSize = prod(sizes) +board = [] +unripe = 0 +index = 0 +deq = deque() + +for line in stdin.read().splitlines(): + for num in map(int, line.split()): + board.append(num) + + if num == 0: + unripe += 1 + + if num == 1: + deq.append(index) + + index += 1 + +if unripe == 0: + print('0') + exit() + +def extract(x): + answer = [0] * 11 + divisor = totalSize + + for i in range(10, -1, -1): + divisor //= sizes[i] + answer[i] = x // divisor + x %= divisor + + return answer + +def compress(ls): + answer = 0 + coefficient = 1 + + for i in range(0, 11): + answer += ls[i] * coefficient + coefficient *= sizes[i] + + return answer + +while deq: + cur = deq.popleft() + positions = extract(cur) + + for i in range(0, 11): + for offset in (-1, 1): + positions[i] += offset + + if 0 <= positions[i] < sizes[i]: + next = compress(positions) + + if board[next] == 0: + board[next] = board[cur] + 1 + unripe -= 1 + deq.append(next) + + positions[i] -= offset + + if unripe == 0: + print(board[cur]) + exit() + +print('-1') \ No newline at end of file From bc9939fdb65eb9080093085ec74584e472c65b15 Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Sun, 4 Feb 2024 23:08:38 +0900 Subject: [PATCH 02/14] 2024-02-04 --- ...\353\260\224\352\274\255\354\247\210 3.py" | 31 +++++++++++++++++++ pknujsp/README.md | 3 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 "pknujsp/BFS/32-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" diff --git "a/pknujsp/BFS/32-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" "b/pknujsp/BFS/32-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" new file mode 100644 index 00000000..e6aa58f5 --- /dev/null +++ "b/pknujsp/BFS/32-\354\210\250\353\260\224\352\274\255\354\247\210 3.py" @@ -0,0 +1,31 @@ +from sys import * +from collections import * + +n, k = map(int, stdin.readline().strip().split()) + +max_idx = 100001 + +q = deque([(n, 0)]) +visited = [False] * max_idx +visited[n] = True + +while q: + x, cost = q.popleft() + if x == k: + print(cost) + break + + nx = x + x + if nx < max_idx and not visited[nx]: + visited[nx] = True + q.appendleft((nx, cost)) + + nx = x - 1 + if 0 <= nx and not visited[nx]: + visited[nx] = True + q.append((nx, cost + 1)) + + nx = x + 1 + if nx < max_idx and not visited[nx]: + visited[nx] = True + q.append((nx, cost + 1)) diff --git a/pknujsp/README.md b/pknujsp/README.md index bdb6a818..d8568f58 100644 --- a/pknujsp/README.md +++ b/pknujsp/README.md @@ -32,4 +32,5 @@ | 28차시 | 2024.01.16 | 그리디 | [무지의 먹방 라이브](https://school.programmers.co.kr/learn/courses/30/lessons/42891) | [#110](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/110) | | 29차시 | 2024.01.18 | DFS, UNION-FIND | [순열 사이클](https://www.acmicpc.net/problem/10451) | [#112](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/112) | | 30차시 | 2024.01.23 | DP | [ABBC](https://www.acmicpc.net/problem/25381) | [#119](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/119) | -| 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | \ No newline at end of file +| 31차시 | 2024.01.30 | SORT | [멀티버스 Ⅱ](https://www.acmicpc.net/problem/18869) | [#123](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/123) | +| 32차시 | 2024.02.04 | BFS | [숨바꼭질 3](https://www.acmicpc.net/problem/13549) | [#127](https://github.com/lgoLeadMe/AlgoLeadMe-1/pull/127) | \ No newline at end of file From fa850b3ddd6f6e4184c114dd8c7822e8ebb68573 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Tue, 6 Feb 2024 20:29:13 +0900 Subject: [PATCH 03/14] 2024-02-06 --- "tgyuuAn/BFS/\352\265\220\355\231\230.py" | 47 +++++++++++++++++++++++ tgyuuAn/README.md | 2 + 2 files changed, 49 insertions(+) create mode 100644 "tgyuuAn/BFS/\352\265\220\355\231\230.py" diff --git "a/tgyuuAn/BFS/\352\265\220\355\231\230.py" "b/tgyuuAn/BFS/\352\265\220\355\231\230.py" new file mode 100644 index 00000000..2429a9b8 --- /dev/null +++ "b/tgyuuAn/BFS/\352\265\220\355\231\230.py" @@ -0,0 +1,47 @@ +from collections import Counter + +number, exchange_count = map(int,input().split()) + +number = list(str(number)) +answer = "0" + +counter = Counter(number) +same_number_flag = False + +for key, value in counter.items(): + if value >=2: + same_number_flag = True + break + +def dfs(number, depth, remain_exchange_count, same_number_flag): + global answer + + if remain_exchange_count == 0: + answer = max(answer, "".join(number)) + return + + flag = False + for prev_idx in range(depth,len(number)): + for next_idx in range(prev_idx+1, len(number)): + if number[next_idx] >= number[prev_idx]: + number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx] + dfs(number, depth+1, remain_exchange_count-1, same_number_flag) + number[next_idx], number[prev_idx] = number[prev_idx], number[next_idx] + flag = True + + if flag == False: + if same_number_flag: dfs(number, depth+1, remain_exchange_count-1, same_number_flag) + else: + number[-1], number[-2] = number[-2], number[-1] + dfs(number, depth+1, remain_exchange_count-1, same_number_flag) + number[-1], number[-2] = number[-2], number[-1] + +if len(number) == 1 and exchange_count >= 1: + print("-1") + +elif len(number) == 2 and "0" in number: + print("-1") + +else: + dfs(number,0, exchange_count, same_number_flag) + print(answer) \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 824c2c6b..77640987 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -35,4 +35,6 @@ | 31차시 | 2023.01.13 | DP | 진우의 달 여행 (Large) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/105 | 32차시 | 2023.01.16 | 그리디 | 멀티탭 스케줄링 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/108 | 34차시 | 2023.01.22 | 힙 | 가운데를 말해요 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/116 +| 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 +| 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 --- From a609481e1d184465f38778ba1bb081a921a17ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Wed, 7 Feb 2024 02:29:13 +0900 Subject: [PATCH 04/14] =?UTF-8?q?2024-02-06=20=ED=94=BC=EC=9E=90=20?= =?UTF-8?q?=EA=B5=BD=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Munbin-Lee/README.md | 1 + ...\354\236\220 \352\265\275\352\270\260.cpp" | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 "Munbin-Lee/\352\265\254\355\230\204/34-\355\224\274\354\236\220 \352\265\275\352\270\260.cpp" diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index 6f7a9aef..eaec7458 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -31,4 +31,5 @@ | 28차시 | 2024.01.16 | 그래프 | 도넛과 막대 그래프 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/109 | | 29차시 | 2024.01.19 | 유니온파인드 | 거짓말 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/114 | | 30차시 | 2024.01.23 | 정수론 | 약수의 합 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/118 | +| 34차시 | 2024.02.06 | 구현 | 피자 굽기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 | --- diff --git "a/Munbin-Lee/\352\265\254\355\230\204/34-\355\224\274\354\236\220 \352\265\275\352\270\260.cpp" "b/Munbin-Lee/\352\265\254\355\230\204/34-\355\224\274\354\236\220 \352\265\275\352\270\260.cpp" new file mode 100644 index 00000000..5cfc7f87 --- /dev/null +++ "b/Munbin-Lee/\352\265\254\355\230\204/34-\355\224\274\354\236\220 \352\265\275\352\270\260.cpp" @@ -0,0 +1,43 @@ +#include +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + + int D, N; + cin >> D >> N; + + stack minOvens; + int mn = 1087654321; + + while (D--) { + int oven; + cin >> oven; + + mn = min(mn, oven); + minOvens.emplace(mn); + } + + while (N--) { + int pizza; + cin >> pizza; + + while (!minOvens.empty() && minOvens.top() < pizza) { + minOvens.pop(); + } + + if (!minOvens.empty()) { + minOvens.pop(); + } else { + cout << '0'; + return 0; + } + } + + cout << minOvens.size() + 1; + + return 0; +} \ No newline at end of file From 45ff738f9167cc89e013866aa3a7de47ca6468e8 Mon Sep 17 00:00:00 2001 From: Yuna Date: Tue, 13 Feb 2024 17:24:27 +0900 Subject: [PATCH 05/14] 29-yuna83 --- yuna83/README.md | 1 + .../\353\270\224\353\241\234\352\267\270.py" | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 "yuna83/\354\212\254\353\235\274\354\235\264\353\224\251\354\234\210\353\217\204\354\232\260/\353\270\224\353\241\234\352\267\270.py" diff --git a/yuna83/README.md b/yuna83/README.md index c77b7df2..e3adb3d6 100644 --- a/yuna83/README.md +++ b/yuna83/README.md @@ -30,4 +30,5 @@ | 26차시 | 2024.01.30 | 딕셔너리 | [귤 고르기](https://school.programmers.co.kr/learn/courses/30/lessons/138476)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/125| | 27차시 | 2024.02.05 | 투포인터 | [좋다](https://www.acmicpc.net/problem/1253)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/129| | 28차시 | 2024.02.07 | 투포인터 | [구명보트](https://school.programmers.co.kr/learn/courses/30/lessons/42885)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/134| +| 29차시 | 2024.02.13 | 슬라이딩윈도우 | [블로그](https://www.acmicpc.net/problem/21921)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/136| --- diff --git "a/yuna83/\354\212\254\353\235\274\354\235\264\353\224\251\354\234\210\353\217\204\354\232\260/\353\270\224\353\241\234\352\267\270.py" "b/yuna83/\354\212\254\353\235\274\354\235\264\353\224\251\354\234\210\353\217\204\354\232\260/\353\270\224\353\241\234\352\267\270.py" new file mode 100644 index 00000000..fccc8bf6 --- /dev/null +++ "b/yuna83/\354\212\254\353\235\274\354\235\264\353\224\251\354\234\210\353\217\204\354\232\260/\353\270\224\353\241\234\352\267\270.py" @@ -0,0 +1,26 @@ +import sys +input=sys.stdin.readline + +n,x=map(int,input().split()) +data=list(map(int,input().split())) + +if max(data) == 0: + print("SAD") +else: + value = sum(data[:x]) # x개씩 윈도우 생성 + max_value=value + max_cnt=1 + + for i in range(x,n): + value+=data[i] + value-=data[i-x] + + if value > max_value: + max_value=value + max_cnt =1 + + elif value == max_value: + max_cnt+=1 + + print(max_value) + print(max_cnt) \ No newline at end of file From 1ba40117b7c95d566b946fc45d785b8529c8e7e5 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Fri, 16 Feb 2024 03:09:12 +0900 Subject: [PATCH 06/14] 2024-02-15 --- ...64\353\202\230\354\271\230 \354\210\230 3.py" | 16 ++++++++++++++++ tgyuuAn/README.md | 1 + 2 files changed, 17 insertions(+) create mode 100644 "tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" diff --git "a/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" "b/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" new file mode 100644 index 00000000..68d10ae3 --- /dev/null +++ "b/tgyuuAn/DP/\355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230 3.py" @@ -0,0 +1,16 @@ +target = int(input()) + +M = 1_000_000 +period = 1_500_000 + +target %= period + +dp_table = [0 for _ in range(3)] +dp_table[0] = 0 +dp_table[1] = 1 + +for idx in range(2,target+1): + idx %= 3 + dp_table[idx] = dp_table[idx-1] % M + dp_table[idx-2] % M + +print(dp_table[target%3]%M) \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 6e5688b1..65a108f7 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,5 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 +| 38차시 | 2023.02.15 | DP | 피보나치 수 3 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/137 --- From 7dcc2d69b28070e822acc04013a65016e2b55599 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Sun, 18 Feb 2024 06:26:36 +0900 Subject: [PATCH 07/14] 2024-02-18 --- "tgyuuAn/DP/\354\225\261.py" | 16 ++++++++++++++++ tgyuuAn/README.md | 1 + 2 files changed, 17 insertions(+) create mode 100644 "tgyuuAn/DP/\354\225\261.py" diff --git "a/tgyuuAn/DP/\354\225\261.py" "b/tgyuuAn/DP/\354\225\261.py" new file mode 100644 index 00000000..a362acdc --- /dev/null +++ "b/tgyuuAn/DP/\354\225\261.py" @@ -0,0 +1,16 @@ +total_app_count, need_memory = map(int,input().split()) + +use_memory = list(map(int,input().split())) +re_use_cost = list(map(int,input().split())) + +dp_table = [0 for _ in range(sum(re_use_cost)+1)] +cost_sum = sum(re_use_cost) + +for memory, cost in zip(use_memory, re_use_cost): + for idx in range(cost_sum,cost-1,-1): + dp_table[idx] = max(dp_table[idx], dp_table[idx-cost] + memory) + +for idx, memory in enumerate(dp_table): + if memory >= need_memory: + print(idx) + break \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 6e5688b1..cdc527cf 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,5 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 +| 38차시 | 2023.02.18 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139 --- From 4ff62d834285589cc5a3562a980306dc3b307f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Sun, 18 Feb 2024 23:51:07 +0900 Subject: [PATCH 08/14] =?UTF-8?q?2024-02-18=20=EB=8B=A8=EC=96=B4=20?= =?UTF-8?q?=EB=A7=88=EB=B0=A9=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Munbin-Lee/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index 62bb882d..338919a6 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -35,4 +35,5 @@ | 32차시 | 2024.01.30 | 백트래킹 | 하이퍼 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 | | 33차시 | 2024.02.04 | 정수론 | 소수 4개의 합 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 | | 34차시 | 2024.02.06 | 구현 | 피자 굽기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 | +| 35차시 | 2024.02.18 | 백트래킹 | 단어 마방진 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/140 | --- From b3f3032ca10f23f84a473d4a43ef40d80509863f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Mon, 19 Feb 2024 23:47:38 +0900 Subject: [PATCH 09/14] =?UTF-8?q?Create=2035-=EB=8B=A8=EC=96=B4=20?= =?UTF-8?q?=EB=A7=88=EB=B0=A9=EC=A7=84.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \353\247\210\353\260\251\354\247\204.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" diff --git "a/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" new file mode 100644 index 00000000..2a235c90 --- /dev/null +++ "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" @@ -0,0 +1,22 @@ +from itertools import permutations + +stdin = open(0) + +L, N = map(int, stdin.readline().split()) +words = sorted(stdin.read().splitlines()) + +# 단어 순열 x가 단어 마방진인지 확인하는 함수 +def isValid(x): + for i in range(L): + for j in range(L): + if x[i][j] != x[j][i]: return False + + return True + +for perm in permutations(words, L): + if not isValid(perm): continue + + print(*perm, sep='\n') + exit() + +print('NONE') \ No newline at end of file From 1d06d18b34031cab9b4cb88e2c4851859d6e1771 Mon Sep 17 00:00:00 2001 From: tgyuu-An Date: Wed, 21 Feb 2024 06:45:43 +0900 Subject: [PATCH 10/14] 2024-02-21 --- "tgyuuAn/DP/\354\236\205\353\214\200.py" | 30 ++++++++++++++++++++++++ tgyuuAn/README.md | 1 + 2 files changed, 31 insertions(+) create mode 100644 "tgyuuAn/DP/\354\236\205\353\214\200.py" diff --git "a/tgyuuAn/DP/\354\236\205\353\214\200.py" "b/tgyuuAn/DP/\354\236\205\353\214\200.py" new file mode 100644 index 00000000..33014b1f --- /dev/null +++ "b/tgyuuAn/DP/\354\236\205\353\214\200.py" @@ -0,0 +1,30 @@ +import sys + +remain_days, need_score = map(int,sys.stdin.readline().split()) +volunteer_scores = [0] +volunteer_scores.extend(list(map(int,sys.stdin.readline().split()))) + +blood_donation_score, blood_donation_break_time = map(int,sys.stdin.readline().split()) + +volunteer_scores.extend([0 for _ in range(blood_donation_break_time-1)]) +maximum_blood_donation_count = (len(volunteer_scores)+blood_donation_break_time-1)//blood_donation_break_time+1 + +dp_table = [[0 for _ in range(maximum_blood_donation_count)] for _ in range(len(volunteer_scores))] + +for date in range(len(volunteer_scores)): + if date >= blood_donation_break_time: + for blood_donation_count in range(1,maximum_blood_donation_count): + dp_table[date][blood_donation_count] = max(dp_table[date][blood_donation_count], + dp_table[date-1][blood_donation_count] + volunteer_scores[date], + dp_table[date-blood_donation_break_time][blood_donation_count-1] + blood_donation_score) + + dp_table[date][0] = dp_table[date-1][0] + volunteer_scores[date] + +print(dp_table) + +for count in range(len(dp_table[-1])): + if dp_table[-1][count] >= need_score: + print(count) + break + +else: print(-1) \ No newline at end of file diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 6e5688b1..cfa788a4 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,5 @@ | 35차시 | 2023.01.25 | 이분 탐색 | 공유기 설치 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/120 | 36차시 | 2023.02.04 | BFS | 로봇 청소기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/126 | 37차시 | 2023.02.04 | BFS | 교환 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/131 +| 40차시 | 2023.02.21 | DP | 입대 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142 --- From 8770ff0b00b6bd29d0424190ffe99e1da6f1bb23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Wed, 21 Feb 2024 23:34:43 +0900 Subject: [PATCH 11/14] =?UTF-8?q?2024-02-21=20=ED=9A=8C=EB=AC=B8=EC=9D=80?= =?UTF-8?q?=20=ED=9A=8C=EB=AC=B8=EC=95=84=EB=8B=88=EC=95=BC!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Munbin-Lee/README.md | 1 + ...354\225\204\353\213\210\354\225\274!!.cpp" | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 "Munbin-Lee/\353\254\270\354\236\220\354\227\264/36-\355\232\214\353\254\270\354\235\200 \355\232\214\353\254\270\354\225\204\353\213\210\354\225\274!!.cpp" diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index 62bb882d..f4cdcc2c 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -35,4 +35,5 @@ | 32차시 | 2024.01.30 | 백트래킹 | 하이퍼 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 | | 33차시 | 2024.02.04 | 정수론 | 소수 4개의 합 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 | | 34차시 | 2024.02.06 | 구현 | 피자 굽기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 | +| 36차시 | 2024.02.21 | 문자열 | 회문은 회문아니야!! | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143 | --- diff --git "a/Munbin-Lee/\353\254\270\354\236\220\354\227\264/36-\355\232\214\353\254\270\354\235\200 \355\232\214\353\254\270\354\225\204\353\213\210\354\225\274!!.cpp" "b/Munbin-Lee/\353\254\270\354\236\220\354\227\264/36-\355\232\214\353\254\270\354\235\200 \355\232\214\353\254\270\354\225\204\353\213\210\354\225\274!!.cpp" new file mode 100644 index 00000000..bb2767ec --- /dev/null +++ "b/Munbin-Lee/\353\254\270\354\236\220\354\227\264/36-\355\232\214\353\254\270\354\235\200 \355\232\214\353\254\270\354\225\204\353\213\210\354\225\274!!.cpp" @@ -0,0 +1,39 @@ +#include +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + + string s; + cin >> s; + + if (unordered_set(s.begin(), s.end()).size() == 1) { + cout << "-1"; + return 0; + } + + auto isPalindrome = [](string &s) { + int lo = 0; + int hi = s.size() - 1; // NOLINT + + while (lo < hi) { + if (s[lo] != s[hi]) return false; + lo++; + hi--; + } + + return true; + }; + + if (!isPalindrome(s)) { + cout << s.size(); + return 0; + } + + cout << s.size() - 1; + + return 0; +} From 00aec03ac0da9ee6633c22c489ad77a58ae03eb3 Mon Sep 17 00:00:00 2001 From: Yuna Date: Fri, 23 Feb 2024 10:14:24 +0900 Subject: [PATCH 12/14] 31-yuna83 --- ...24\354\235\264\353\237\254\354\212\244.py" | 21 +++++++++++++++++++ yuna83/README.md | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 "yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" diff --git "a/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 00000000..059ac612 --- /dev/null +++ "b/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,21 @@ +cnt=0 +def DFS(virus): + global cnt + visited[virus]=1 + + for i in network[virus]: + if (visited[i]==0): + DFS(i) + cnt+=1 + +N= int(input()) +link = int(input()) + +network = [[]*(N+1) for _ in range(N+1)] +for i in range(link): + a, b = map(int, input().split()) + network[a].append(b) + network[b].append(a) +visited = [0]*(N+1) +DFS(1) +print(cnt) diff --git a/yuna83/README.md b/yuna83/README.md index c77b7df2..68ecc54f 100644 --- a/yuna83/README.md +++ b/yuna83/README.md @@ -30,4 +30,7 @@ | 26차시 | 2024.01.30 | 딕셔너리 | [귤 고르기](https://school.programmers.co.kr/learn/courses/30/lessons/138476)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/125| | 27차시 | 2024.02.05 | 투포인터 | [좋다](https://www.acmicpc.net/problem/1253)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/129| | 28차시 | 2024.02.07 | 투포인터 | [구명보트](https://school.programmers.co.kr/learn/courses/30/lessons/42885)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/134| +| 29차시 | 2024.02.13 | 슬라이딩윈도우 | [블로그](https://www.acmicpc.net/problem/21921)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/136| +| 30차시 | 2024.02.19 | 슬라이딩윈도우 | [도둑](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141| +| 31차시 | 2024.02.23 | DFS/BFS | [바이러스](https://www.acmicpc.net/problem/2606)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/145| --- From 9345d14be6672f08bd94197cba346ac731d01b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Mon, 26 Feb 2024 14:03:15 +0900 Subject: [PATCH 13/14] Create test.md --- test.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.md diff --git a/test.md b/test.md new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/test.md @@ -0,0 +1 @@ +test From 33f3cd9aed2c067baad840fac1854b61031d6fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Mon, 26 Feb 2024 14:04:15 +0900 Subject: [PATCH 14/14] Delete test.md --- test.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test.md diff --git a/test.md b/test.md deleted file mode 100644 index 9daeafb9..00000000 --- a/test.md +++ /dev/null @@ -1 +0,0 @@ -test