cswork / OA打开练习工作台

TradeDeskOA #5

Flights

简单可在线判题

考点(AI 标注)二分查找模拟/实现

You are given two flight timetables, C→D and D→C, each sorted by departure time in ascending order, and the planned number of round trips. Each leg takes 100 minutes; when departing from the current city, take the earliest flight whose departure time is not earlier than the current time. Simulate all round trips and return the time of the final arrival at C; if any leg has no flight to take, return -1.

输入格式

The first line contains n, m, and journeys: the numbers of flights in the two directions and the planned number of round trips. The second line contains n C→D departure times in non-decreasing order; the third line contains m D→C departure times in non-decreasing order. Constraints: 1≤n,m≤100000, 1≤journeys≤min(n,m), 0≤every departure time≤10^9. A flight departing exactly at the arrival time can be taken.

输出格式

Output the arrival time after completing all planned round trips; if they cannot be completed, output -1.

样例 1

输入:

3 3 1
0 200 500
99 210 450

输出:

310

样例说明

The original text of this function-style problem has no standard input/output protocol; this site adds a serialization based on the array lengths and the two timetable lines. Boarding at exactly the arrival time is established by the lower_bound/bisect_left rule in the source code.