結果

問題 No.2111 Sum of Diff
コンテスト
ユーザー paruf4
提出日時 2022-10-28 23:19:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 301 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 381 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 108,800 KB
最終ジャッジ日時 2026-03-27 12:54:22
合計ジャッジ時間 5,659 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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