Range Reconstruction
시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2022 December SilverBOJ 26974
문제
Bessie has an array , where and for all . She won't tell you itself, but she will tell you the range of each subarray of . That is, for each pair of indices , Bessie tells you . Given these values of , please construct an array that could have been Bessie's original array. The values in your array should be in the range .
입력
The first line contains .
Another lines follow. The th of these lines contains the integers .
It is guaranteed that there is some array with values in the range such that for all , .
출력
Output one line containing integers in the range representing your array. They must satisfy for all .
예제
예제 1
입력
3 0 2 2 0 1 0
출력
1 3 2
예제 2
입력
3 0 1 1 0 0 0
출력
0 1 1
예제 3
입력
4 0 1 2 2 0 1 1 0 1 0
출력
1 2 3 2
예제 4
입력
4 0 1 1 2 0 0 2 0 2 0
출력
1 2 2 0
코드를 제출하려면 로그인하세요.