No.2938 Sigma Sigma Distance Distance Problem
レベル :
/ AI推定難易度 : 115
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 179
作問者 :
kazuppa
/ テスター :
yuusaan
kakao745
hirayuu_yc
タグ : / 解いたユーザー数 179
作問者 :
kazuppa
/ テスター :
問題文最終更新日: 2024-10-18 21:43:18
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.
Back to the original
yukicoder contest 450
(順位表)
の他の問題:
Problem Statement
You are given an integer sequence $A_1,A_2,\ ...\ , A_{N}$ of length $N$. $\\$ Find $\left(\displaystyle\sum_{i=1}^{N}\displaystyle\sum_{j=1}^{N} \ \left|i-j\right| \times \left|A_i-A_j\right|\right)$.
Input
The input is given from standard input in the following format.$N$
$A_1\ \ A_2\ ... \ A_{N}$
Constraints
- $1\leq N\leq 100$
- $1\leq A_i\leq 100(1\leq i\leq N)\\$
- All inputs are integers.
Constraints for the evil cases
- $1\leq N\leq 2\times 10^5$
- $1\leq A_i\leq 500(1\leq i\leq N)$
- All inputs are integers.
Output
Print $\left(\displaystyle\sum_{i=1}^{N}\displaystyle\sum_{j=1}^{N} \ \left|i-j\right| \times \left|A_i-A_j\right|\right)$ on one line, followed by a newline.
Sample
Sample 1
Input
2 3 2
Output
2
The value of $(|i-j| \times |A_i-A_j|)$ for each $(i,j)$ is as follows.
Sample 2
Input
3 1 2 3
Output
12
Sample 3
Input
9 41 15 76 69 70 58 10 20 34
Output
7196
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。