#SRD0000148. Theo dõi đoàn tàu (Train Tracking)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Theo dõi đoàn tàu (Train Tracking)
Train Tracking
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
A train has carriages numbered through . Carriage has an integer identifier . The same train is observed twice in the same carriage order. Determine the minimum identifier in every group of exactly consecutive carriages.
For every starting index between and , define
Output these minima in increasing order of .
PHOJ adaptation notice: The original problem uses a two-pass grader, 5,500 persistent integer notebook slots, a limit of 25 million get/set calls, and a required helpBessie callback. This standard-I/O PHOJ package checks the numerical minima but does not automatically enforce the original grader's restricted persistent state. A separate grader kit is supplied for faithful testing.
Input
- The first line contains two integers and .
- The second line contains integers in carriage order.
Output
Print lines. Line contains the minimum identifier among carriages through .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
10 3
5 7 9 2 0 1 7 4 3 6
Output
5
2
0
0
0
1
3
3
Explanation
Here , . The eight consecutive windows are [5,7,9], [7,9,2], [9,2,0], [2,0,1], [0,1,7], [1,7,4], [7,4,3], and [4,3,6]. Their minima are , respectively, matching the eight output lines.