From bace85de4ec463ce8caf04d5592861f41c1a4367 Mon Sep 17 00:00:00 2001 From: SUMIN Date: Sat, 11 Apr 2026 11:56:14 +0900 Subject: [PATCH] =?UTF-8?q?Upload=20files=20to=20"=EB=B0=B1=EC=A4=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 백준/10844.py | 21 +++++++++++++++++++++ 백준/10868.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 백준/10989.py | 12 ++++++++++++ 백준/9465.py | 21 +++++++++++++++++++++ 백준/9663.py | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 백준/10844.py create mode 100644 백준/10868.py create mode 100644 백준/10989.py create mode 100644 백준/9465.py create mode 100644 백준/9663.py diff --git a/백준/10844.py b/백준/10844.py new file mode 100644 index 0000000..28d28ae --- /dev/null +++ b/백준/10844.py @@ -0,0 +1,21 @@ +import sys + +input = sys.stdin.readline + +N = int(input()) + +a = [] +for i in range(N): + a.append(list(map(int, input().split()))) + +DP_table = [[0 for _ in range(3)] for _ in range(N+1)] + +DP_table[0][0] = a[0][0] +DP_table[0][1] = a[0][1] +DP_table[0][2] = a[0][2] + +for i in range(1, N): + for j in range(3): + DP_table[i][j] = min(DP_table[i-1][(j+1)%3], DP_table[i-1][(j+2)%3]) + a[i][j] + +print(min(DP_table[N-1][0],DP_table[N-1][1],DP_table[N-1][2])) \ No newline at end of file diff --git a/백준/10868.py b/백준/10868.py new file mode 100644 index 0000000..01e4904 --- /dev/null +++ b/백준/10868.py @@ -0,0 +1,44 @@ +import sys + +input = sys.stdin.readline + +n, m = map(int, input().split()) + +height = 0 +length = n + +while length != 0: + length //= 2 + height += 1 + +tree_size = pow(2, height+1) +tree_start_index = pow(2, height) - 1 +tree = [sys.maxsize] * (tree_size+1) + +for i in range(n): + tree[tree_start_index+i+1] = int(input()) + +temp = n + tree_start_index + +while temp != 1: + tree[temp//2] = min(tree[temp//2], tree[temp]) + temp-=1 + +def find_tree(a,b): + result = sys.maxsize + while a<=b: + if (a%2==1): + result = min(result, tree[a]) + a+=1 + if (b%2==0): + result = min(result, tree[b]) + b-=1 + a //= 2 + b //= 2 + return result + +for _ in range(m): + s_i, e_i = map(int, input().split()) + s_i += tree_start_index + e_i += tree_start_index + print(find_tree(s_i, e_i)) diff --git a/백준/10989.py b/백준/10989.py new file mode 100644 index 0000000..0918c40 --- /dev/null +++ b/백준/10989.py @@ -0,0 +1,12 @@ +import sys + +N = int(sys.stdin.readline().rstrip()) +arr=[0] * 10001 +for i in range(N): + temp=int(sys.stdin.readline().rstrip()) + arr[temp]+=1 + +for i in range(10001): + if(arr[i]!=0): + for j in range(arr[i]): + print(i) \ No newline at end of file diff --git a/백준/9465.py b/백준/9465.py new file mode 100644 index 0000000..96b2c25 --- /dev/null +++ b/백준/9465.py @@ -0,0 +1,21 @@ +import sys +import math + +input = sys.stdin.readline + +T = int(input().strip()) # 테스트 케이스 개수 +for i in range(T): + arr = [] # 스티커 가중치 + total = 0 + n = int(input().strip()) # 가로 행의 크기 + arr.append(list(map(int,input().split()))) + arr.append(list(map(int,input().split()))) + dp = [[0]*3 for i in range(n)] + dp[0][0] = 0 + dp[0][1] = arr[0][0] + dp[0][2] = arr[1][0] + for i in range(1, n): + dp[i][0] = max(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + arr[0][i] + dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[1][i] + print(max(dp[n-1][0], dp[n-1][1], dp[n-1][2])) \ No newline at end of file diff --git a/백준/9663.py b/백준/9663.py new file mode 100644 index 0000000..99c18c6 --- /dev/null +++ b/백준/9663.py @@ -0,0 +1,37 @@ +import sys + +input = sys.stdin.readline + +n = int(input().strip()) + +colUsed = [False] * (n) +diagUsed = [False] * ((2*n)-1) +AntidiagUsed = [False] * ((2*n)-1) + +tot = 0 + +def placeQueens(row): + global tot + + if (row == n): + tot+=1 + return + + for col in range(n): + diagIndex = row - col + n - 1 + AntiDiagIndex = row + col + + if not colUsed[col] and not diagUsed[diagIndex] and not AntidiagUsed[AntiDiagIndex]: + colUsed[col] = True + diagUsed[diagIndex] = True + AntidiagUsed[AntiDiagIndex] = True + + placeQueens(row + 1) + + colUsed[col] = False + diagUsed[diagIndex] = False + AntidiagUsed[AntiDiagIndex] = False + + +placeQueens(0) +print(tot)