본문 바로가기
  • KEEP HUSTLE!

백준60

[백준 2565] 전깃줄 - Python(파이썬) import sys N = int(sys.stdin.readline().strip()) arr = [] for _ in range(N): a, b = map(int, sys.stdin.readline().split()) arr.append((a, b)) arr.sort() check = [1] * N for i in range(N-1, -1, -1): mymax = 0 for j in range(i, N): if arr[j][1] > arr[i][1] and check[j] > mymax: mymax = check[j] check[i] += mymax print(N - max(check)) 2021. 3. 4.
[백준 11054] 가장 긴 바이토닉 부분 수열 - Python(파이썬) 바이토닉 수열 : 다음의 규칙을 가진 수열 계속 증가하는.. (1, 2, 3, 4) 계속 감소하는.. (4, 3, 2, 1) 증가 후 감소하는.. (1, 2, 3, 4, 5, 10, 6, 5, 2, 1) import sys def solution(): for i in range(N): for j in range(i, N): if arr[i] = check2[j]: check2[j] += 1 if arr[-i - 1] = check[-j - 1]: check[-j - 1] += 1 for i in range(N): check[i] += check2[i] - 1 return max(check) N = int.. 2021. 3. 4.
[백준 12865] 평범한 배낭 - Python(파이썬) 냅색을 이용해서 풀기 import sys def solution(): for i in range(1, N+1): for j in range(K+1): weight = data[i-1][0] value = data[i-1][1] if j >= weight: check[i][j] = max(check[i-1][j-weight] + value, check[i-1][j]) else: check[i][j] = check[i-1][j] N, K = map(int, sys.stdin.readline().split()) data = [] check = [[0]*(K+1) for _ in range(N+1)] for _ in range(N): a, b = map(int, sys.stdin.readline().split(.. 2021. 3. 4.
[백준 14425] 문자열 집합 - Python(파이썬) '트라이'로 풀지 않은 코드 import sys N, M = map(int, sys.stdin.readline().split()) toCheck = {sys.stdin.readline().strip() for _ in range(N)} answer = 0 for _ in range(M): if sys.stdin.readline().strip() in toCheck: answer += 1 print(answer) 2021. 3. 4.
[백준 2740] 행렬 곱셈 - Python(파이썬) import sys N, M = map(int, sys.stdin.readline().split()) arr1, arr2 = [], [] for _ in range(N): arr1.append(list(map(int, sys.stdin.readline().split()))) A, B = map(int, sys.stdin.readline().split()) for _ in range(A): arr2.append(list(map(int, sys.stdin.readline().split()))) result = [[0] * B for _ in range(N)] for n in range(N): # 0 1 2 for m in range(B): # 0 1 2 for a in range(A): # 0 1 resul.. 2021. 3. 4.
[백준 1629] 곱셈 - Python(파이썬) import sys def solution(x, y): if y == 1: return x % C else: result = solution(x, y // 2) if y % 2: return result * result * x % C else: return result * result % C A, B, C = map(int, sys.stdin.readline().split()) print(pow(A, B, C)) print(solution(A, B)) 2021. 3. 4.