問題一覧 > 通常問題

No.3469 Number of Inversions in Judge Results

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 49
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 2161 / 自分の提出
問題文最終更新日: 2026-03-06 22:31:39
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

$N$ submissions were made in order to an online judge. Each of these submissions is assigned to a different judge server, and the execution time of submission $i$ is $A_i$ milliseconds.

When submission $i$ was submitted before submission $j$ ($i < j$) but its execution time is longer ($A_i > A_j$), so that the order in which the results are returned is reversed, this is called an inversion.

Find the number of inversions.

Input

$N$
$A_1\ A_2\ \ldots\ A_N$
All constraints are integers.
  • $1 \le N \le 200{,}000$
  • $1 \le A_i \le 10^9$

Output

Output the number of inversions on one line.

Print a newline at the end.

Sample

Sample 1
Input
4
3 1 4 1
Output
3

Submission 1 (3ms) and submission 2 (1ms): submission 2 returns first → inversion
Submission 1 (3ms) and submission 4 (1ms): submission 4 returns first → inversion
Submission 3 (4ms) and submission 4 (1ms): submission 4 returns first → inversion

Sample 2
Input
3
1 2 3
Output
0

The execution times are in ascending order of submission, so no inversions occur.

Sample 3
Input
3
3 2 1
Output
3

Inversions occur in all pairs.

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