Solved by 646 users: ...
UserDateAttemptTimeCMSC
Nakilon12 jan 2010Ruby300.1145
stasg726 nov 2009Ruby1300.1277
stasg727 nov 2009Ruby1400.1282
stasg726 nov 2009Ruby1200.1283
zhuojie29 oct 2009Python103.6985
abortmozga.ru09 jul 2010C++1300.2987
stasg726 nov 2009Ruby1100.1288
karthiekc23 mar 2010Ruby1300.1490
abortmozga.ru09 jul 2010C++1100.2891
abortmozga.ru09 jul 2010C++1200.2891
abortmozga.ru09 jul 2010C++1000.2895
UlyaNick21 mar 2009Ruby100.13101
karthiekc23 mar 2010Ruby1200.14109
DAV23 jun 2009C++600.37109
WsemirZ27 dec 2007Kylix800.13114
WsemirZ27 dec 2007Kylix1400.13115
WsemirZ27 dec 2007Kylix1500.13115
WsemirZ27 dec 2007Kylix1600.13115
abortmozga.ru09 jul 2010C++600.26123
ethanhunt31 may 2007C++300.09125
 C++ 315 FPC 177 C 106 Java 30 Kylix 21 Ruby 4 Python 2
>
>
>
>
>
>
>
>
>
>

## Reconstructing permutation

Time limit = 3 second(s)

Memory limit = 32000

Petya has shuffled numbers 1,2, .. N and placed them into array A[1..N]. Then he created a new array B[1..N], in which element B[i] represents the number of elements in array A with index >i that are greater than element with index i.

Given array B could you reconstruct initial array A ?

If it is possible you should output array A, otherwise output "-1" without quotes.

Input The number N (1 < N < 10000) folowed by N elements of array B.

Output Elements of array A or "-1".

 Input#14 1 1 1 0 Output#13 2 1 4
 Input#25 2 2 2 2 2 Output#2-1
 Input#310 0 0 0 0 0 0 0 0 0 0 Output#310 9 8 7 6 5 4 3 2 1

Author: