#FT0000242. Lễ trưởng thành (Coming of Age Celebration)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lễ trưởng thành (Coming of Age Celebration)
Coming of Age Celebration
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A planet has aliens, all currently minors. Alien owns stones and will become an adult exactly years from now. No additional aliens will be born.
Whenever an alien becomes an adult, every alien who became an adult earlier and still has at least one stone gives exactly one stone to the newly grown adult. An adult with no stones gives nothing. These events occur in years .
Determine the number of stones owned by each alien after year .
Input
- The first line contains the integer .
- The second line contains exactly integers in alien index order.
Output
Print exactly space-separated integers , where is the final number of stones held by alien .
Subtasks
-
Subtask 1 (20 points): ; for all .
-
Subtask 2 (30 points): ; for all .
-
Subtask 3 (50 points): ; for all .
Examples
Input
4
5 0 9 3
Output
2 0 10 5
Explanation
Initially the stone counts are . After year , no older adult can give a stone: . In year , alien gives one stone to alien : . In year , aliens and give stones to alien : . In year , aliens and give stones to alien while alien is empty, leaving .