結果

問題 No.2941 Sigma Music Game Score Problem
コンテスト
ユーザー ra5anchor
提出日時 2024-10-18 22:05:04
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 729 ms / 2,500 ms
コード長 472 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 259 ms
コンパイル使用メモリ 85,316 KB
実行使用メモリ 312,700 KB
最終ジャッジ日時 2026-05-05 15:33:37
合計ジャッジ時間 9,637 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

M, N = map(int, input().split())
X = list(map(int, input().split()))
MOD = 998244353

def inv(x):
    return pow(x, MOD-2, MOD)
def sm(x):
    res = x * (x+1) * (2*x+1)
    res *= inv(6)
    res %= MOD
    return res

L = []
prev = 0
for i in range(N):
    x = X[i]
    if x - prev - 1 > 0:
        L.append(x - prev - 1)
    prev = x
x = M+1
if x - prev - 1 > 0:
    L.append(x - prev - 1)
# print(L)

ans = 0
for item in L:
    ans += sm(item)
    ans %= MOD
print(ans)
0