300436: CF83B. Doctor
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Doctor
题意翻译
**题意简述** 给定一个包含 $n$ 个数的序列 $a_1,a_2,\dots,a_n$($1\le n\le 10^5$),$a_i$ 的编号为 $i$,注意编号不会因为序列的变化而改变。 现在请你执行 $k$($0\le k\le 10^{14}$)次操作,每次操作为取出序列的第一个数并将其值减一,若其值大于 $0$,则将其放到序列的最尾端,否则出队。 求最后的序列剩下的数的编号(若 $k$ 次操作还未执行完序列已经为空则输出 `-1`)。 **样例说明** 样例 $1$ 初始:$a=\{1,2,1\}$。 第一次操作后:$a=\{2,1\}$,剩余编号为 $2,3$。 第二次操作后:$a=\{1,1\}$,剩余编号为 $3,2$。 第三次操作后:$a=\{1\}$,剩余编号为 $2$。 样例 $3$ 初始:$a=\{1,3,3,1,2,3,1\}$。 第一次操作后:$a=\{3,3,1,2,3,1\}$,剩余编号为 $2,3,4,5,6,7$。 第二次操作后:$a=\{3,1,2,3,1,2\}$,剩余编号为 $3,4,5,6,7,2$。 第三次操作后:$a=\{1,2,3,1,2,2\}$,剩余编号为 $4,5,6,7,2,3$。 第四次操作后:$a=\{2,3,1,2,2\}$,剩余编号为 $5,6,7,2,3$。 第五次操作后:$a=\{3,1,2,2,1\}$,剩余编号为 $6,7,2,3,5$。 第六次操作后:$a=\{1,2,2,1,2\}$,剩余编号为 $7,2,3,5,6$。 第七次操作后:$a=\{2,2,1,2\}$,剩余编号为 $2,3,5,6$。 第八次操作后:$a=\{2,1,2,1\}$,剩余编号为 $3,5,6,2$。 第九次操作后:$a=\{1,2,1,1\}$,剩余编号为 $5,6,2,3$。 第十次操作后:$a=\{2,1,1\}$,剩余编号为 $6,2,3$。题目描述
There are $ n $ animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number $ i $ in the queue will have to visit his office exactly $ a_{i} $ times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home. Doctor plans to go home after receiving $ k $ animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out.输入输出格式
输入格式
The first line of input data contains two space-separated integers $ n $ and $ k $ ( $ 1<=n<=10^{5} $ , $ 0<=k<=10^{14} $ ). In the second line are given space-separated integers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=10^{9} $ ). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).
输出格式
If the doctor will overall carry out less than $ k $ examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted.
输入输出样例
输入样例 #1
3 3
1 2 1
输出样例 #1
2
输入样例 #2
4 10
3 3 2 1
输出样例 #2
-1
输入样例 #3
7 10
1 3 3 1 2 3 1
输出样例 #3
6 2 3