인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

mm07416847's profile image
mm07416847

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

6. Stacking the tallest tower (LIS application)

이 코드는 어떤가요

Written on

·

231

0

import sys

sys.stdin=open("input.txt","rt")

n = int(input())
a = []
dp = [0] * (n+1)

for i in range(n):
a.append(list(map(int, input().split())))

a = sorted(a, key =lambda x: x[0])

for i in range(n):
dp[i] = a[i][1]

for i in range(1, n):
for j in range(i):
if a[i][2] > a[j][2]:
dp[i] = max(dp[i] , dp[j] + a[i][1])

print(max(dp))
 
역순으로 문제를 해결해보려다가 뭔가가 잘 안풀려서 그냥 정렬로 문제를 해결해보았습니다.
 
코테 준비 같이 해요! python

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

잘 하신 코드입니다.

mm07416847's profile image
mm07416847

asked

Ask a question