목차

Cow Jog

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()