結果

問題 No.1331 Moving Penguin
ユーザー chineristACchineristAC
提出日時 2020-10-30 17:45:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 880 ms / 1,500 ms
コード長 669 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 339,360 KB
最終ジャッジ日時 2024-04-25 04:35:45
合計ジャッジ時間 33,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
85,948 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 AC 37 ms
57,088 KB
testcase_03 AC 38 ms
57,344 KB
testcase_04 AC 759 ms
338,964 KB
testcase_05 AC 756 ms
339,056 KB
testcase_06 AC 734 ms
338,932 KB
testcase_07 AC 741 ms
338,664 KB
testcase_08 AC 742 ms
338,644 KB
testcase_09 AC 741 ms
338,520 KB
testcase_10 AC 751 ms
338,900 KB
testcase_11 AC 734 ms
338,912 KB
testcase_12 AC 743 ms
339,036 KB
testcase_13 AC 754 ms
338,904 KB
testcase_14 AC 739 ms
338,776 KB
testcase_15 AC 736 ms
338,760 KB
testcase_16 AC 724 ms
338,520 KB
testcase_17 AC 725 ms
338,904 KB
testcase_18 AC 728 ms
338,736 KB
testcase_19 AC 752 ms
338,904 KB
testcase_20 AC 732 ms
338,892 KB
testcase_21 AC 744 ms
339,012 KB
testcase_22 AC 731 ms
338,516 KB
testcase_23 AC 738 ms
338,904 KB
testcase_24 AC 744 ms
338,776 KB
testcase_25 AC 748 ms
338,772 KB
testcase_26 AC 762 ms
338,968 KB
testcase_27 AC 765 ms
339,096 KB
testcase_28 AC 765 ms
338,912 KB
testcase_29 AC 751 ms
338,848 KB
testcase_30 AC 297 ms
160,072 KB
testcase_31 AC 455 ms
216,248 KB
testcase_32 AC 261 ms
141,312 KB
testcase_33 AC 371 ms
191,488 KB
testcase_34 AC 532 ms
251,896 KB
testcase_35 AC 792 ms
338,976 KB
testcase_36 AC 875 ms
338,848 KB
testcase_37 AC 880 ms
339,108 KB
testcase_38 AC 300 ms
160,036 KB
testcase_39 AC 755 ms
330,660 KB
testcase_40 AC 408 ms
197,760 KB
testcase_41 AC 741 ms
338,844 KB
testcase_42 AC 829 ms
339,232 KB
testcase_43 AC 827 ms
339,048 KB
testcase_44 AC 818 ms
339,048 KB
testcase_45 AC 851 ms
339,284 KB
testcase_46 AC 880 ms
339,360 KB
testcase_47 AC 874 ms
339,036 KB
testcase_48 AC 740 ms
338,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

assert 1<=N<=10**5
assert len(A)==N
assert all(1<=A[i]<=N for i in range(N))

A = [0] + A
mod = 10**9 + 7

dp = [0 for i in range(N+1)]
data = [[0 for i in range(320)] for j in range(N)]
dp[-1] = 1
for j in range(1,min(N,320)):
    data[N-j][j] = 1

for i in range(N-1,0,-1):
    if A[i]**2 > N:
        for j in range(A[i],N+1-i,A[i]):
            dp[i] += dp[i+j]
            dp[i] %= mod
    else:
        dp[i] = data[i][A[i]]

    if A[i]!=1:
        dp[i] += dp[i+1]
        dp[i] %= mod

    for j in range(1,min(320,i)):
        data[i - j][j] = data[i][j] + dp[i]
        data[i - j][j] %= mod

print(dp[1])
0