結果

問題 No.2111 Sum of Diff
ユーザー paruf4
提出日時 2022-10-28 23:19:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,520 KB
最終ジャッジ日時 2024-07-06 02:34:24
合計ジャッジ時間 2,781 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
tot = sum(a)
mod = 998244353
res = 0
if n == 2:
    res += (a[0]-a[-1])
    res %= mod
    print(res)
    exit(0)
cur = n
for aa in a:
    cur -= 1
    res += (aa*cur)-(tot-aa)
    tot -= aa
    res %= mod
res += (a[0]-a[-1])
res %= mod
print(res)
0