結果

問題 No.1294 マウンテン数列
ユーザー vwxyzvwxyz
提出日時 2022-09-27 05:22:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 8,612 KB
最終ジャッジ日時 2023-08-24 03:34:51
合計ジャッジ時間 1,678 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 15 ms
7,796 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 16 ms
7,972 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