Delayed Signals (Delay) : OIS2021 - Round 2
Delayed Signals (Delay) : OIS2021 - Round 2
Delayed Signals (Delay) : OIS2021 - Round 2
0 5 8 9 7 10 4 1.
since it reports the same values as the original sequence in order, repeating the first three times and
skipping the last two, with every integer in output being produced with the requested delay of two
(except for the first with a delay of zero and the second with a delay of one, which are the maximum
delays possible).
Suppose now that the delay amount is varying over time: 5 4 3 2 1 0 2 1, with the same input se-
quence. Then, the most accurate output is:
0 0 0 5 9 10 10 4.
The first three values are 0, with delays 0, 1, and 2 respectively, which is as close as you can get to
the requested 5, 4, 3. The following values 5, 9, 10 match exactly the requested delays of 2, 1 and 0
respectively. The following value, 10, has a delay of 1 (instead of the requested 2), which is as much
as possible given that you have to respect the order of the original sequence. Finally, 4 conclude the
sequence with the requested delay of 1.
+ Among the attachments of this task you may find a template file delay.* with a sample
incomplete implementation.
Input
The first line contains the only integer N . The second line contains N integers St . The third line contains
N integers Dt .
delay Page 1 of 2
Output
You need to write a single line with N integers Ot : the delayed signal.
Constraints
• 1 ≤ N ≤ 100 000.
• −109 ≤ St ≤ 109 for each t = 0 . . . N − 1.
• 0 ≤ Dt < N for each t = 0 . . . N − 1.
• The integers in the input sequence St are all distinct.
Scoring
Your program will be tested against several test cases grouped in subtasks. In order to obtain the score
of a subtask, your program needs to correctly solve all of its test cases.
– Subtask 1 (0 points) Examples.
– Subtask 2 (30 points) N ≤ 100 and Dt = Dt0 for every t, t0 .
– Subtask 3 (20 points) N ≤ 1000.
– Subtask 4 (15 points) Dt = Dt0 for every t, t0 .
– Subtask 5 (35 points) No additional limitations.
Examples
input output
8 0 0 0 5 8 9 7 10
0 5 8 9 7 10 4 1
2 2 2 2 2 2 2 2
8 0 0 0 5 9 10 10 4
0 5 8 9 7 10 4 1
5 4 3 2 1 0 2 1
delay Page 2 of 2