| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 6656 |
| 문제명 | Railway Transportation |
| 레벨 | 골드 2 |
| 분류 |
LIS |
| 시간복잡도 | O(nlogn) |
| 인풋사이즈 | n<=200,000 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 57068KB / 364ms |
| 최고기록 | 364ms |
| 해결날짜 | 2026/01/22 |
"""Solution code for "BOJ 6656. Railway Transportation".
- Problem link: https://www.acmicpc.net/problem/6656
- Solution link: http://www.teferi.net/ps/problems/boj/6656
Tags: [LIS]
"""
import sys
from teflib import psutils
from teflib import seqtask
@psutils.run_until_all_zero
def main():
N, M = [int(x) for x in sys.stdin.readline().split()]
nums = [int(x) for x in sys.stdin.readline().split()]
lengths = seqtask.longest_dec_subseq_length_by_last_elem(nums, strict=True)
if max(lengths) > M:
print('Transportation failed')
else:
print(*lengths)
print(*(lengths[i] for i in sorted(range(N), key=nums.__getitem__)))
if __name__ == '__main__':
main()