問題一覧 > 通常問題

No.1300 Sum of Inversions

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 260
作問者 : nok0 / テスター : noya2 Kite_kuma
お気に入りにしたユーザー ProblemId : 5438 / 自分の提出
問題文最終更新日: 2020-11-28 00:16:26
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. Back to the original
yukicoder contest 276 (順位表) の他の問題:

Problem Statement

You are given a sequence $A$ of non-negative integers of length $N$. The $i$-th number is $A_i$.

For all tuples $(i, j, k)$ satisfying $i < j < k$ and $A_i > A_j > A_k$, find the sum of $A_i+A_j+A_k$.

Since the sum can be very large, output the remainder when it is divided by $998244353$.

Constraints

  • All inputs are integers.
  • $3 \le N\le 2 × 10^5$
  • $0 \le A_i \le 10^9$

Input

$N$
$A_1\ A_2 \ \dots \  A_N$

Output

Output the remainder when the sum of $A_i+A_j+A_k$ over all tuples $(i, j, k)$ satisfying $i < j < k$ and $A_i > A_j > A_k$ is divided by $998244353$.

Sample

Sample 1
Input
3
3 2 1
Output
6

There is $1$ tuple $(i,j,k)$ satisfying the conditions: $(1,2,3)$. Since $A_1 + A_2 +A_3 = 6$, the answer is $6$.

Sample 2
Input
4
4 2 3 1
Output
15

There are $2$ tuples $(i,j,k)$ satisfying the conditions: $(1,2,4), (1,3,4)$. The values of $A_i+A_j+A_k$ are $7,8$ respectively, so the answer is $15$.

Sample 3
Input
10
3 1 4 1 5 9 2 6 5 3
Output
69

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