| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 9702 |
| 문제명 | LIS |
| 레벨 | 골드 1 |
| 분류 |
가장 긴 증가하는 부분 수열 |
| 시간복잡도 | O(T * n^2logn) |
| 인풋사이즈 | T<=?, n<=500 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 37036KB / 1280ms |
| 최고기록 | 1020ms |
| 해결날짜 | 2026/01/11 |
"""Solution code for "BOJ 9702. LIS".
- Problem link: https://www.acmicpc.net/problem/9702
- Solution link: http://www.teferi.net/ps/problems/boj/9702
Tags: [lis]
"""
import collections
import sys
from teflib import psutils
from teflib import seqtask
@psutils.gcj_style
def main():
N = int(sys.stdin.readline())
s = collections.deque(int(sys.stdin.readline()) for _ in range(N))
answer = 0
for _ in range(N):
length = 0
for l in seqtask.longest_inc_subseq_lengths_by_last_elem(s):
if l > length:
length = l
answer += length
s.popleft()
print(answer)
if __name__ == '__main__':
main()