#P2008. 大朋友的数字
大朋友的数字
Description
There is a group of “big friends” (age or above). Each of them holds a number, which has exactly digit, i.e., it is between and . The score of each big friend is defined as the sum of all numbers in the longest non-decreasing subsequence that appears before them and ends at them. (This sequence must end at that person!) If there are multiple longest non-decreasing subsequences, choose the one whose sequence of indices is lexicographically smallest. Now you are given big friends and their numbers. Please compute the score of each person.
Input Format
The first line contains number .
The second line contains numbers, representing each person’s number.
Output Format
Output numbers in one line, representing each person’s score.
5
1 2 5 3 4
1 3 8 6 10
5
1 7 5 9 6
1 8 6 17 12
Hint
[Sample Explanation ]
The five scores are , , , , .
[Sample Explanation ]
The five scores are , , , (there is also ), .
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号