| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 125 | 23 | 23 | 23.958% |
There is a one-lane, one-way road from Budapest Airport to Hotel Forrás. The road is $L$ kilometres long.
Over the IOI 2023 event, $N+1$ transfer buses traverse this road. Buses are numbered from 0ドル$ to $N$. Bus $i$ (0ドル \le i \lt N$) is scheduled to leave the airport at the $T[i]$-th second of the event, and can travel 1ドル$ kilometre in $W[i]$ seconds. Bus $N$ is a reserve bus that can travel 1ドル$ kilometre in $X$ seconds. The time $Y$ when it will leave the airport has not yet been decided.
Overtaking is not allowed on the road in general, but the buses are allowed to overtake each other at sorting stations. There are $M$ ($M \gt 1$) sorting stations, numbered from 0ドル$ to $M - 1,ドル on different positions on the road. Sorting station $j$ (0ドル \le j \lt M$) is located $S[j]$ kilometres from the airport along the road. The sorting stations are sorted in increasing distance from the airport, that is, $S[j] \lt S[j+1]$ for each 0ドル \le j \le M - 2$. The first sorting station is the airport and the last one is the hotel, that is, $S[0] = 0$ and $S[M-1] = L$.
Each bus travels at maximum speed unless it catches up to a slower bus travelling ahead of it on the road, in which case they get bunched and forced to travel at the speed of the slower bus, until they reach the next sorting station. There, the faster buses will overtake the slower buses.
Formally, for each $i$ and $j$ such that 0ドル \le i \le N$ and 0ドル \le j \lt M,ドル the time $t_{i,j}$ (in seconds) when bus $i$ arrives at sorting station $j$ is defined as follows. Let $t_{i,0} = T[i]$ for each 0ドル \le i \lt N,ドル and let $t_{N,0} = Y$. For each $j$ such that 0ドル \lt j \lt M$:
The IOI organizers want to schedule the reserve bus (bus $N$). Your task is to answer $Q$ questions of the organizers, which are of the following form: given the time $Y$ (in seconds) when the reserve bus is supposed to leave the airport, at what time would it arrive at the hotel?
Your task is to implement the following procedures.
void init(int L, int N, int64[] T, int[] W, int X, int M, int[] S)
arrival_time.
int64 arrival_time(int64 Y)
Consider the following sequence of calls:
init(6, 4, [20, 10, 40, 0], [5, 20, 20, 30], 10, 4, [0, 1, 3, 6])
Ignoring bus 4ドル$ (that has not yet been scheduled), the following table shows the expected and actual times of arrivals for non-reserve buses at each sorting station:
| $i$ | $t_{i,0}$ | $e_{i,1}$ | $t_{i,1}$ | $e_{i,2}$ | $t_{i,2}$ | $e_{i,3}$ | $t_{i,3}$ |
|---|---|---|---|---|---|---|---|
| 0ドル$ | 20ドル$ | 25ドル$ | 30ドル$ | 40ドル$ | 40ドル$ | 55ドル$ | 55ドル$ |
| 1ドル$ | 10ドル$ | 30ドル$ | 30ドル$ | 70ドル$ | 70ドル$ | 130ドル$ | 130ドル$ |
| 2ドル$ | 40ドル$ | 60ドル$ | 60ドル$ | 100ドル$ | 100ドル$ | 160ドル$ | 180ドル$ |
| 3ドル$ | 0ドル$ | 30ドル$ | 30ドル$ | 90ドル$ | 90ドル$ | 180ドル$ | 180ドル$ |
The times of arrivals at station 0ドル$ are the times at which buses are scheduled to leave the airport. That is, $t_{i,0} = T[i]$ for 0ドル \le i \le 3$.
The expected and actual times of arrivals at sorting station 1ドル$ are computed as follows:
arrival_time(0)
Bus 4ドル$ takes 10ドル$ seconds to travel 1ドル$ kilometre and is now scheduled to leave the airport at the 0ドル$-th second. In this case, the following table shows the times of arrivals for each bus. The only change regarding the expected and actual arrival times of the non-reserve buses is underlined.
| $i$ | $t_{i,0}$ | $e_{i,1}$ | $t_{i,1}$ | $e_{i,2}$ | $t_{i,2}$ | $e_{i,3}$ | $t_{i,3}$ |
|---|---|---|---|---|---|---|---|
| 0ドル$ | 20ドル$ | 25ドル$ | 30ドル$ | 40ドル$ | 40ドル$ | 55ドル$ | $\underline{60}$ |
| 1ドル$ | 10ドル$ | 30ドル$ | 30ドル$ | 70ドル$ | 70ドル$ | 130ドル$ | 130ドル$ |
| 2ドル$ | 40ドル$ | 60ドル$ | 60ドル$ | 100ドル$ | 100ドル$ | 160ドル$ | 180ドル$ |
| 3ドル$ | 0ドル$ | 30ドル$ | 30ドル$ | 90ドル$ | 90ドル$ | 180ドル$ | 180ドル$ |
| 4ドル$ | 0ドル$ | 10ドル$ | 10ドル$ | 30ドル$ | 30ドル$ | 60ドル$ | 60ドル$ |
We see that bus 4ドル$ arrives at the hotel at the 60ドル$-th second. Thus, the procedure should return 60ドル$.
arrival_time(50)
Bus 4ドル$ is now scheduled to leave the airport at the 50ドル$-th second. In this case, there are no changes in the times of arrivals for the non-reserve buses compared to the initial table. The times of arrivals are shown in the following table.
| $i$ | $t_{i,0}$ | $e_{i,1}$ | $t_{i,1}$ | $e_{i,2}$ | $t_{i,2}$ | $e_{i,3}$ | $t_{i,3}$ |
|---|---|---|---|---|---|---|---|
| 0ドル$ | 20ドル$ | 25ドル$ | 30ドル$ | 40ドル$ | 40ドル$ | 55ドル$ | 55ドル$ |
| 1ドル$ | 10ドル$ | 30ドル$ | 30ドル$ | 70ドル$ | 70ドル$ | 130ドル$ | 130ドル$ |
| 2ドル$ | 40ドル$ | 60ドル$ | 60ドル$ | 100ドル$ | 100ドル$ | 160ドル$ | 180ドル$ |
| 3ドル$ | 0ドル$ | 30ドル$ | 30ドル$ | 90ドル$ | 90ドル$ | 180ドル$ | 180ドル$ |
| 4ドル$ | 50ドル$ | 60ドル$ | 60ドル$ | 80ドル$ | 90ドル$ | 120ドル$ | 130ドル$ |
Bus 4ドル$ overtakes the slower bus 2ドル$ at sorting station 1ドル$ as they arrive at the same time. Next, bus 4ドル$ gets bunched with bus 3ドル$ between station 1ドル$ and station 2ドル,ドル making bus 4ドル$ arrive at station 2ドル$ at the 90ドル$-th second instead of the 80ドル$-th. After leaving station 2ドル,ドル bus 4ドル$ gets bunched with bus 1ドル$ up until they arrive at the hotel. Bus 4ドル$ arrives at the hotel at the 130ドル$-th second. Thus, the procedure should return 130ドル$.
We can plot the time it takes for each bus to arrive at each distance from the airport. The x-axis of the plot represents the distance from the airport (in kilometres) and the y-axis of the plot represents the time (in seconds). Vertical dashed lines mark the positions of the sorting stations. Different solid lines (accompanied by the bus indices) represent the four non-reserve buses. The dotted black line represents the reserve bus.
arrival_time(0) |
arrival_time(50) |
|---|---|
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 9 | $N = 1, Q \le 1,000円$ |
| 2 | 10 | $M = 2, Q \le 1,000円$ |
| 3 | 20 | $N, M, Q \le 100$ |
| 4 | 26 | $Q \le 5,000円$ |
| 5 | 35 | No additional constraints. |
The sample grader reads the input in the following format:
The sample grader prints your answers in the following format:
arrival_time for question $k$Olympiad > International Olympiad in Informatics > IOI 2023 > Day 2 5번
C++17, C++20, C++17 (Clang), C++20 (Clang)