結果

問題 No.1331 Moving Penguin
ユーザー chineristACchineristAC
提出日時 2020-10-30 16:25:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,063 ms / 1,500 ms
コード長 763 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 339,748 KB
最終ジャッジ日時 2024-04-25 04:33:01
合計ジャッジ時間 39,468 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
86,400 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 44 ms
57,344 KB
testcase_03 AC 42 ms
57,344 KB
testcase_04 AC 892 ms
338,068 KB
testcase_05 AC 868 ms
338,172 KB
testcase_06 AC 854 ms
337,920 KB
testcase_07 AC 845 ms
337,848 KB
testcase_08 AC 855 ms
337,768 KB
testcase_09 AC 853 ms
338,012 KB
testcase_10 AC 858 ms
338,256 KB
testcase_11 AC 851 ms
337,760 KB
testcase_12 AC 856 ms
338,012 KB
testcase_13 AC 852 ms
338,140 KB
testcase_14 AC 863 ms
338,024 KB
testcase_15 AC 857 ms
337,884 KB
testcase_16 AC 845 ms
338,012 KB
testcase_17 AC 874 ms
337,760 KB
testcase_18 AC 885 ms
337,756 KB
testcase_19 AC 866 ms
338,020 KB
testcase_20 AC 853 ms
337,756 KB
testcase_21 AC 854 ms
338,004 KB
testcase_22 AC 854 ms
338,024 KB
testcase_23 AC 842 ms
337,896 KB
testcase_24 AC 849 ms
337,892 KB
testcase_25 AC 854 ms
337,892 KB
testcase_26 AC 886 ms
338,008 KB
testcase_27 AC 884 ms
338,196 KB
testcase_28 AC 869 ms
338,076 KB
testcase_29 AC 862 ms
338,040 KB
testcase_30 AC 336 ms
161,024 KB
testcase_31 AC 516 ms
217,192 KB
testcase_32 AC 293 ms
141,952 KB
testcase_33 AC 399 ms
179,456 KB
testcase_34 AC 583 ms
251,356 KB
testcase_35 AC 941 ms
338,208 KB
testcase_36 AC 959 ms
337,828 KB
testcase_37 AC 935 ms
338,164 KB
testcase_38 AC 342 ms
160,768 KB
testcase_39 AC 862 ms
329,544 KB
testcase_40 AC 458 ms
198,400 KB
testcase_41 AC 831 ms
338,024 KB
testcase_42 AC 930 ms
338,072 KB
testcase_43 AC 919 ms
338,292 KB
testcase_44 AC 927 ms
338,080 KB
testcase_45 AC 1,051 ms
339,724 KB
testcase_46 AC 1,042 ms
339,236 KB
testcase_47 AC 1,063 ms
339,748 KB
testcase_48 AC 822 ms
337,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [0] + list(map(int,input().split()))
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(1,N+1):
            tmp = i + j * A[i]
            if tmp<N+1:
                dp[i] += dp[tmp]
                dp[i] %= mod
            else:
                break
        if A[i]!=1:
            dp[i] += dp[i+1]
            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