#arc175c. C - Jumping Through Intervals
C - Jumping Through Intervals
Score: points
问题陈述
给定 对整数 。这里,对于所有 ,有 。
如果满足以下条件,那么一个由 个整数组成的序列 被称为 好整数序列:
- 对于所有 ,有 。
找到字典序最小的 好整数序列 ,使得 最小化。
序列的字典序是什么?
如果满足以下 1. 或 2. 中的任一条件,我们说序列 字典序小于序列 。这里, 分别表示 和 的长度。
- 并且 $(S_1,S_2,\ldots,S_{|S|}) = (T_1,T_2,\ldots,T_{|S|})$。
- 存在一个整数 使得以下两个条件同时成立:
- $(S_1,S_2,\ldots,S_{i-1}) = (T_1,T_2,\ldots,T_{i-1})$。
- 数字上小于 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given pairs of integers . Here, for all .
A sequence of integers is called a good integer sequence if it satisfies the following condition:
- for all .
Find the lexicographically smallest good integer sequence that minimizes .
What is lexicographical order for sequences?
A sequence is said to be lexicographically smaller than a sequence if 1. or 2. below holds. Here, denote the lengths of and , respectively.
- and $(S_1,S_2,\ldots,S_{|S|}) = (T_1,T_2,\ldots,T_{|S|})$.
- There is an integer such that both of the following hold:
- $(S_1,S_2,\ldots,S_{i-1}) = (T_1,T_2,\ldots,T_{i-1})$.
- is smaller than (as a number).
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer in a single line in the following format:
Sample Input 1
4
1 10
8 13
3 4
5 20
Sample Output 1
8 8 4 5
is a good integer sequence. In this case, $\sum_{i = 1}^{N-1} |A_{i+1} - A_{i}| = |8 - 8| + |4 - 8| + |5 - 4| = 5$, which is the minimum value of .
Sample Input 2
3
20 24
3 24
1 75
Sample Output 2
20 20 20
Note that when multiple good integer sequences minimize , you should print the lexicographically smallest of them.
Sample Input 3
15
335279264 849598327
446755913 822889311
526239859 548830120
181424399 715477619
342858071 625711486
448565595 480845266
467825612 647639160
160714711 449656269
336869678 545923679
61020590 573085537
626006012 816372580
135599877 389312924
511429216 547865075
561330066 605997004
539239436 921749002
Sample Output 3
526239859 526239859 526239859 467825612 467825612 467825612 467825612 449656269 449656269 449656269 626006012 389312924 511429216 561330066 561330066