問題一覧 > 通常問題

No.3470 Sum of Execution Time Differences

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 49
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 2213 / 自分の提出
問題文最終更新日: 2026-10-20 14:57:29
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder 2026新ジャッジ contest (順位表) の他の問題:

Problem Statement

There are $N$ submissions. The execution time of the $i$-th submission is $T_i$ milliseconds.

Find the sum of the absolute differences in execution time $|T_i - T_j|$ over all pairs $(i, j)$ ($1 \le i < j \le N$).

Input

$N$
$T_1\ T_2\ \ldots\ T_N$
All constraints are integers.

  • $2 \le N \le 200{,}000$
  • $0 \le T_i \le 10^8$

Partial Score

This problem has partial scoring based on subtasks.

SubtaskScoreConstraints
small40% (100 pts)N ≤ 1,000
large30% (75 pts)追加の制約なし
ランダムlarge30% (75 pts)追加の制約なし

Output

Print $\displaystyle\sum_{1 \le i < j \le N} |T_i - T_j|$ on one line. End the output with a newline.

Sample

Sample 1
Input
3
1 3 6
Output
10

$|1-3| + |1-6| + |3-6| = 2 + 5 + 3 = 10$

Sample 2
Input
2
5 5
Output
0

All values are the same, so the difference is 0.

Sample 3
Input
4
1 2 3 4
Output
10

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。