cswork / OA打开练习工作台

IBMOA #8

User Sessions

估计简单可在线判题

考点(AI 标注)哈希计数原地数组

Sort each user's events by time; consecutive events whose time difference does not exceed t belong to the same session, otherwise a new session starts. Find the total number of sessions across all users. Different users are never merged.

输入格式

The first line contains n t, followed by n lines of user ID and time. On this site 1≤n≤200000, 0≤time,t≤10^12; an ID is 1 to 32 ASCII letters or digits; events may be out of order or repeated.

输出格式

Output one integer, the answer.

样例 1

输入:

5 10
a 1
b 2
a 5
a 100
b 3

输出:

3

样例 2

输入:

3 10
a 0
a 10
a 20

输出:

1

样例 3

输入:

3 0
a 1
a 1
b 1

输出:

2

样例说明

The examples give 3, 1 and 2 respectively; a gap exactly equal to the timeout still stays in the same session.