PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000030. Đoạn đường dài nhất chưa có đèn (Traffic Lights)
HỌC THEO LỘ TRÌNH
3 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đoạn đường dài nhất chưa có đèn (Traffic Lights)
Traffic Lights
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
A street extends from coordinate to coordinate . Initially there are no traffic lights. Add traffic lights one by one at distinct interior positions. After each addition, determine the length of the longest interval without a light between consecutive lights or between a light and an endpoint.
Input
The first line contains . The second line contains the pairwise distinct positions in insertion order.
Output
Print integers, separated by spaces: the longest gap after each insertion.
Subtasks
- Subtask 1 (20 points): ; ; ; all are distinct.
- Subtask 2 (30 points): ; ; ; all are distinct.
- Subtask 3 (50 points): ; ; ; all are distinct.
Examples
Input
8 3
3 6 2
Output
5 3 3
Explanation
After insertions at 3,6,2, the largest gap lengths are 5,3,3.