No.3470 Sum of Execution Time Differences
問題文最終更新日: 2026-10-20 14:57:29
English (AI translation)
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.
| Subtask | Score | Constraints |
|---|---|---|
| small | 40% (100 pts) | N ≤ 1,000 |
| large | 30% (75 pts) | 追加の制約なし |
| ランダムlarge | 30% (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もしくは右上の雲マークをクリックしてアカウントを作成してください。