結果

問題 No.2111 Sum of Diff
ユーザー paruf4
提出日時 2022-10-28 23:49:58
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 513 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 848,856 KB
最終ジャッジ日時 2024-07-06 03:09:49
合計ジャッジ時間 3,163 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other MLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
s = [0]*n
for i in range(1,n):
    s[i] = s[i-1] + 2**(i-1)
# print(s)
res = 0
mod = 998244353
for i in range(n-1):
    res += (a[i]-a[-1+i])*s[-1+i]
    res %= mod
print(res)


# 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