結果

問題 No.992 最長増加部分列の数え上げ
コンテスト
ユーザー %20
提出日時 2020-02-06 01:01:09
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 456 ms / 2,000 ms
+ 43µs
コード長 361 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 305 ms
コンパイル使用メモリ 21,596 KB
実行使用メモリ 45,920 KB
最終ジャッジ日時 2026-09-03 21:49:43
合計ジャッジ時間 18,996 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect

inf=2*10**9
MD=10**9+7

N=int(input())
A=map(int,input().split())
dp1=[-inf]
dp2=[[-inf,inf]]
dp4=[[0,1]]
for a in A:
	x=bisect.bisect_left(dp1,a)
	if x==len(dp1):
		dp1+=[a]
		dp2+=[[-inf]]
		dp4+=[[0]]
	else:
		dp1[x]=a
	dp2[x]+=[-a]
	y=bisect.bisect_right(dp2[x-1],-a)-1;
	dp4[x]+=[(dp4[x][-1]+dp4[x-1][-1]-dp4[x-1][y])%MD]
print(dp4[-1][-1])
0