ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 10651 |
문제명 | Cow Jog |
레벨 | 플래티넘 5 |
분류 |
LIS |
시간복잡도 | O(nlogn) |
인풋사이즈 | n<=100,000 |
사용한 언어 | Python |
제출기록 | 36652KB / 220ms |
최고기록 | 220ms |
해결날짜 | 2021/06/29 |
"""Solution code for "BOJ 10651. Cow Jog".
- Problem link: https://www.acmicpc.net/problem/10651
- Solution link: http://www.teferi.net/ps/problems/boj/10651
Tags: [LIS]
"""
import bisect
import sys
MOD = 10_007
def main():
N, T = [int(x) for x in sys.stdin.readline().split()]
final_pos = []
for _ in range(N):
pos, speed = [int(x) for x in sys.stdin.readline().split()]
final_pos.append(pos + speed * T)
# Longest non-increasing sequence.
arr = []
for x in final_pos:
lis_len = bisect.bisect_right(arr, -x)
if lis_len == len(arr):
arr.append(-x)
else:
arr[lis_len] = -x
print(len(arr))
if __name__ == '__main__':
main()