#abc331c. C - Sum of Numbers Greater Than Me

C - Sum of Numbers Greater Than Me

Score : 300300 points

问题描述

你已给出一个长度为 NN 的序列 A=(A1,,AN)A=(A_1,\ldots,A_N)

对于每个 i=1,,Ni=1,\ldots,N,解决以下问题:

问题:找出 AA 中所有大于 AiA_i 的元素之和。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a sequence A=(A1,,AN)A=(A_1,\ldots,A_N) of length NN.

For each i=1,,Ni=1,\ldots,N, solve the following problem.

Problem: Find the sum of all elements in AA that are greater than AiA_i.

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • 1Ai1061 \leq A_i \leq 10^6
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 \ldots ANA_N

Output

For each 1kN1\leq k\leq N, let BkB_k be the answer to the problem when i=ki=k. Print B1,,BNB_1,\ldots,B_N in this order, separated by spaces.

Sample Input 1

5
1 4 1 4 2

Sample Output 1

10 0 10 0 8
  • For i=1i=1, the sum of elements greater than A1=1A_1=1 is 4+4+2=104+4+2=10.
  • For i=2i=2, the sum of elements greater than A2=4A_2=4 is 00.
  • For i=3i=3, the sum of elements greater than A3=1A_3=1 is 4+4+2=104+4+2=10.
  • For i=4i=4, the sum of elements greater than A4=4A_4=4 is 00.
  • For i=5i=5, the sum of elements greater than A5=2A_5=2 is 4+4=84+4=8.

Sample Input 2

10
31 42 59 26 53 58 97 93 23 54

Sample Output 2

456 414 190 487 361 249 0 97 513 307

Sample Input 3

50
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sample Output 3

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

update @ 2024/3/10 01:15:19