From 0dc3905f0ab21407f9f0dd6e66bce4c37a038e86 Mon Sep 17 00:00:00 2001 From: wnsmir <163817041+wnsmir@users.noreply.github.com> Date: Mon, 25 Nov 2024 20:54:05 +0900 Subject: [PATCH 1/2] 8-wnsmir --- ...40\354\236\220\353\245\264\352\270\260.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "wnsmir/\352\262\260\354\240\225\353\254\270\354\240\234/1654\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" diff --git "a/wnsmir/\352\262\260\354\240\225\353\254\270\354\240\234/1654\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" "b/wnsmir/\352\262\260\354\240\225\353\254\270\354\240\234/1654\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..1c46bdf --- /dev/null +++ "b/wnsmir/\352\262\260\354\240\225\353\254\270\354\240\234/1654\353\236\234\354\204\240\354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,22 @@ +def max_lan_length(K, N, lengths): + start, end = 1, max(lengths) # 최소 1, 최대 길이 설정 + result = 0 + + while start <= end: + mid = (start + end) // 2 # 중간값 설정 + count = sum(l // mid for l in lengths) # mid 길이로 잘라서 만들 수 있는 랜선 개수 계산 + + if count >= N: # N개 이상 만들 수 있으면 + result = mid # 현재 길이를 저장 + start = mid + 1 # 더 긴 길이를 시도 + else: + end = mid - 1 # 더 짧은 길이를 시도 + + return result + +# 입력 처리 +K, N = map(int, input().split()) +lengths = [int(input()) for _ in range(K)] + +# 결과 출력 +print(max_lan_length(K, N, lengths)) \ No newline at end of file From e288bf1c1e92dd16fcdca62218f7e2d24f064801 Mon Sep 17 00:00:00 2001 From: wnsmir <163817041+wnsmir@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:57:00 +0900 Subject: [PATCH 2/2] 10-wnsmir --- ...2\260\234\353\257\270\354\240\204\354\202\254.py" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "wnsmir/DP/\352\260\234\353\257\270\354\240\204\354\202\254.py" diff --git "a/wnsmir/DP/\352\260\234\353\257\270\354\240\204\354\202\254.py" "b/wnsmir/DP/\352\260\234\353\257\270\354\240\204\354\202\254.py" new file mode 100644 index 0000000..dd82ef9 --- /dev/null +++ "b/wnsmir/DP/\352\260\234\353\257\270\354\240\204\354\202\254.py" @@ -0,0 +1,12 @@ +N = int(input()) + +Food = list(map(int, input().split())) + +dp = [0]*(N+1) +dp[1] = Food[0] +dp[2] = max(Food[0], Food[1]) + +for i in range(4, N+1): + dp[i] = max(dp[i-2]+Food[i-1], dp[i-1]) + +print(dp[N]) \ No newline at end of file