#BS0000202. Bài kiểm tra của Sakurako (Sakurako's Test)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bài kiểm tra của Sakurako (Sakurako's Test)
Sakurako's Test
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Sakurako has an array of positive integers. For a given positive , she may repeatedly select an index with and subtract from that element. The median is the element at one-based position after sorting, including the right middle position for even . For each of values of , determine the minimum attainable median. Queries independently start with the original array.
Input
The first line gives integers , the array length and query count. The second gives integers . Each of the next lines contains one integer .
Output
Print integers on one line, in query order.
Subtasks
- Subtask 1 (20 points): ; for ; in each query.
- Subtask 2 (30 points): ; for ; in each query.
- Subtask 3 (50 points): ; for ; in each query.
Examples
Input
5 5
1 2 3 4 5
1
2
3
4
5
Output
0 1 1 1 2
Explanation
For each x, reducing every entry as far as permitted yields sorted arrays [0,0,0,0,0], [0,0,1,1,1], [0,1,1,2,2], [0,1,1,2,3], and [0,1,2,3,4]. The third entry gives the five answers. No entry can be reduced below its remainder.