結果

問題 No.1331 Moving Penguin
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-14 09:02:02
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 614 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 500,344 KB
最終ジャッジ日時 2023-09-28 19:52:12
合計ジャッジ時間 23,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
76,808 KB
testcase_01 AC 78 ms
71,128 KB
testcase_02 AC 75 ms
71,172 KB
testcase_03 AC 75 ms
71,128 KB
testcase_04 AC 129 ms
111,048 KB
testcase_05 TLE -
testcase_06 AC 1,472 ms
432,716 KB
testcase_07 AC 1,479 ms
432,456 KB
testcase_08 AC 151 ms
104,564 KB
testcase_09 AC 148 ms
104,636 KB
testcase_10 AC 151 ms
104,356 KB
testcase_11 AC 156 ms
100,204 KB
testcase_12 AC 158 ms
100,232 KB
testcase_13 AC 153 ms
100,252 KB
testcase_14 AC 237 ms
131,072 KB
testcase_15 AC 238 ms
131,304 KB
testcase_16 AC 240 ms
131,108 KB
testcase_17 AC 157 ms
99,752 KB
testcase_18 AC 155 ms
99,576 KB
testcase_19 AC 154 ms
100,828 KB
testcase_20 AC 127 ms
95,956 KB
testcase_21 AC 124 ms
96,132 KB
testcase_22 AC 124 ms
95,880 KB
testcase_23 AC 162 ms
100,456 KB
testcase_24 AC 157 ms
100,708 KB
testcase_25 AC 156 ms
100,760 KB
testcase_26 AC 323 ms
106,760 KB
testcase_27 AC 331 ms
110,856 KB
testcase_28 AC 335 ms
109,408 KB
testcase_29 AC 99 ms
92,272 KB
testcase_30 AC 180 ms
89,380 KB
testcase_31 AC 201 ms
91,376 KB
testcase_32 AC 154 ms
82,872 KB
testcase_33 AC 191 ms
90,784 KB
testcase_34 AC 225 ms
93,948 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 144 ms
83,584 KB
testcase_39 AC 334 ms
113,196 KB
testcase_40 AC 207 ms
87,268 KB
testcase_41 TLE -
testcase_42 AC 482 ms
167,560 KB
testcase_43 AC 389 ms
167,968 KB
testcase_44 AC 385 ms
166,748 KB
testcase_45 AC 195 ms
115,908 KB
testcase_46 AC 198 ms
116,120 KB
testcase_47 AC 202 ms
116,288 KB
testcase_48 AC 101 ms
90,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
dp=[0]*n
mod=10**9+7
dp[0]=1
ary=[{} for i in range(n)]
base=0
for i in range(n):
  # マスiに到達するケースを加算
  if ary[i]:
    for k,v in ary[i].items():
      dp[i]=(dp[i]+v)%mod
      if i+k<n:
        if k in ary[i+k]:
          ary[i+k][k]+=v
        else:
          ary[i+k][k]=v
  dp[i]+=base
  dp[i]%=mod
  if i==n-1:break
  k=a[i]
  if k==1:
    base+=dp[i]
    base%=mod
  else:
    dp[i+1]+=dp[i]
    if i+k<n:
      if k in ary[i+k]:
        ary[i+k][k]+=dp[i]
        ary[i+k][k]%=mod
      else:
        ary[i+k][k]=dp[i]
print(dp[-1])
0