본문 바로가기
  • KEEP HUSTLE!

전체 글73

[백준 9251] LCS - Python(파이썬) import sys def solution(): for i in range(len(str1)): temp = 0 for j in range(len(str2)): if temp < check[j]: temp = check[j] elif str1[i] == str2[j]: check[j] = temp + 1 return max(check) str1 = sys.stdin.readline().strip() str2 = sys.stdin.readline().strip() check = [0] * len(str2) print(solution()) 2021. 3. 9.
[HacKerRank SQL] SQL Project Planning - MYSQL You are given a table, Projects, containing three columns: Task_ID, Start_Date and End_Date. It is guaranteed that the difference between the End_Date and the Start_Date is equal to 1 day for each row in the table. If the End_Date of the tasks are consecutive, then they are part of the same project. Samantha is interested in finding the total number of different projects completed. Write a query.. 2021. 3. 9.
[백준 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.