結果

問題 No.1294 マウンテン数列
ユーザー vwxyzvwxyz
提出日時 2022-09-27 05:22:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 77,552 KB
最終ジャッジ日時 2023-08-24 03:34:55
合計ジャッジ時間 2,614 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 73 ms
71,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 74 ms
71,280 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
M=10
cnt=[0]*M
mod=998244353
for d in range(M-1,-1,-1):
    if any(A[i+1]-A[i]>d for i in range(N-1)):
        break
    dp=[0]*(N+1)
    r=N
    dp[N-1]=1
    for l in range(N-3,-1,-1):
        while A[r-1]-A[l]>d:
            r-=1
        dp[l+1]=(dp[l+2]+dp[l+2]-dp[r])%mod
    cnt[d]=dp[1]*2%mod
for i in range(M-1,0,-1):
    cnt[i]-=cnt[i-1]
    cnt[i]%=mod
ans=sum(d*cnt[d]%mod for d in range(M))%mod
print(ans)
0