ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 18353 |
문제명 | 병사 배치하기 |
레벨 | 실버 2 |
분류 |
LIS |
시간복잡도 | O(nlogn) |
인풋사이즈 | n<=2000 |
사용한 언어 | Python |
제출기록 | 32928KB / 72ms |
최고기록 | 56ms |
해결날짜 | 2022/02/27 |
"""Solution code for "BOJ 18353. 병사 배치하기".
- Problem link: https://www.acmicpc.net/problem/18353
- Solution link: http://www.teferi.net/ps/problems/boj/18353
Tags: [LIS]
"""
import bisect
def main():
N = int(input()) # pylint: disable=unused-variable
nums = [int(x) for x in input().split()]
arr = []
for num in reversed(nums):
pos = bisect.bisect_left(arr, num)
if pos == len(arr):
arr.append(num)
else:
arr[pos] = num
print(N - len(arr))
if __name__ == '__main__':
main()