cswork / OA打开练习工作台

RobloxOA #13

Schedule Meeting

估计中等可在线判题

考点(AI 标注)前缀和区间贪心调度

Given each employee's busy intervals within a day and the meeting length, find the earliest start minute at which all employees are free and the meeting can finish within the day; if there is none, output -1. Added by this site: times use half-open intervals [start,finish), so touching endpoints do not conflict; input intervals may overlap or be out of order.

输入格式

The first line contains n length; for each employee, the number of intervals m is given, followed by m pairs start finish. 1≤n≤100, 0≤m≤100, 0≤start<finish≤1400, 1≤length≤1440.

输出格式

Output the earliest start time; if no time works, output -1.

样例 1

输入:

2 120
2
60 150
180 240
2
0 210
360 420

输出:

240

样例 2

输入:

3 180
1
480 510
1
240 330
1
375 400

输出:

0

样例 3

输入:

1 1440
1
0 1400

输出:

-1