| 2025 USP Try-outs |
|---|
| Finished |
Due to the high rent prices in Shanghai, Kai, of the Yafa clan, has become homeless. Fortunately, he has already found a new place! However, he will need to wait for exactly $$$D$$$ days until he can move in.
In the meantime, he has evaluated his options and found $$$N$$$ places, represented by indices from $$$1$$$ to $$$N$$$, where he can spend the night. Each place, however, has a tolerance limit: after a certain number of consecutive days, Kai will be kicked out.
For each of the $$$N$$$ places, an integer $$$d_i$$$ has been determined, representing the maximum number of consecutive days he can sleep at the $$$i$$$-th location before being expelled. It is possible that $$$d_i = 0$$$; in this case, it means Kai cannot spend even a single night at that location.
Your goal is to create an accommodation plan for Kai to get through the $$$D$$$ days by alternating between these places, without exceeding the consecutive day limit of any of them. Kai can return to a place later, as long as each new consecutive stay respects the limit.
Write a program that determines if it is possible to create such a plan. If so, produce a sequence of places (indices from $$$1$$$ to $$$N$$$), indicating where Kai should sleep on each of the $$$D$$$ days. Otherwise, print $$$-1$$$.
The first line contains two integers $$$N$$$ and $$$D$$$ ($$$1 \leq N, D \leq 10^5$$$), representing the number of available places and the number of days Kai needs to wait, respectively.
The second line contains $$$N$$$ integers $$$d_1, d_2, \ldots, d_N$$$ ($$$0 \leq d_i \leq 10^5$$$), where $$$d_i$$$ is the tolerance limit of the $$$i$$$-th place.
Print $$$D$$$ integers, the sequence of places representing the accommodation plan. If it is not possible to create a plan, print $$$-1$$$.
3 50 1 3
2 3 3 3 2
10 10 0 0 0 0 0 0 0 0 0
-1
| Name |
|---|


