結果

問題 No.992 最長増加部分列の数え上げ
ユーザー brthyyjpbrthyyjp
提出日時 2020-02-15 08:06:27
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 720 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 847,856 KB
最終ジャッジ日時 2024-04-16 03:07:23
合計ジャッジ時間 2,919 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 37 ms
52,224 KB
testcase_02 AC 38 ms
52,352 KB
testcase_03 AC 37 ms
52,616 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
l = list(map(int, input().split()))

MOD = 10**9+7

import bisect

dp0 = [float('inf')]*(n+1)
dp0[0] = -float('inf')
# dp[i]: 長さiの増加部分列の末尾の要素の最小値(できないときはfloat('inf')

dp1 = [[float('inf')]*(n+1) for j in range(n+1)]
for i in range(n+1):
    dp1[i][0] = -float('inf')

cnt = [0]*(n+1)
cnt[0] = 1
M = 0

dp2 = [[0]*(n+1) for _ in range(n+1)]
dp2[0][1] = 1

for i in range(n):
  a = l[i]
  x = bisect.bisect_left(dp0, a)
  dp0[x] = min(dp0[x], a)
  cnt[x] += 1
  M = max(x, M)
  dp1[x][cnt[x]] = -a
  y = bisect.bisect(dp1[x-1], -a)-1
  dp2[x][cnt[x]] += (dp2[x][cnt[x]-1]+dp2[x-1][cnt[x-1]]-dp2[x-1][y])%MOD

#print(dp2)
#print(M)
print(dp2[M][cnt[M]])
0