diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index f4cdcc2c..79bc19ee 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -35,5 +35,6 @@ | 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 | | 36차시 | 2024.02.21 | 문자열 | 회문은 회문아니야!! | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/143 | --- 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 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/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/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..530f4f4a 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -39,4 +39,7 @@ | 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 +| 39차시 | 2023.02.18 | DP | | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/139 +| 40차시 | 2023.02.21 | DP | 입대 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/142 --- 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