PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000130. Tổng các số lớn hơn phần tử hiện tại (Sum of Numbers Greater Than Me)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng các số lớn hơn phần tử hiện tại (Sum of Numbers Greater Than Me)
Sum of Numbers Greater Than Me
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers , for each index calculate the sum of all array elements strictly greater than . Equal-valued elements do not contribute. Count repeated larger values at all their distinct positions. Return results in original array order.
Input
The first line contains . The second line contains integers .
Output
Print integers; integer is the sum of elements strictly greater than .
Subtasks
- Subtask 1 (20 points): ; , .
- Subtask 2 (30 points): ; , .
- Subtask 3 (50 points): ; , .
Examples
Input
5
1 4 1 4 2
Output
10 0 10 0 8
Explanation
For value (positions 1 and 3), larger elements are , summing to . For value (positions 2 and 4), there is no larger value so the sum is . For (position 5), the two values sum to . Output 10 0 10 0 8.