結果

問題 No.1804 Intersection of LIS
ユーザー kozykozy
提出日時 2022-01-07 22:57:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 72,968 KB
最終ジャッジ日時 2024-04-26 18:53:37
合計ジャッジ時間 9,191 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 30 ms
10,880 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 27 ms
10,752 KB
testcase_32 WA -
testcase_33 AC 28 ms
10,624 KB
testcase_34 WA -
testcase_35 AC 617 ms
72,964 KB
testcase_36 AC 578 ms
72,968 KB
testcase_37 AC 246 ms
40,636 KB
testcase_38 AC 249 ms
40,636 KB
testcase_39 AC 27 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import bisect
#i番目までの増加列の長さを返す
def LIS(lis):
  c=len(lis)
  dp=[lis[0]]
  this=0
  ansl=[]
  for i in range(c):
    a=lis[i]
    if a>dp[-1]:
      dp.append(a)
      this=len(dp)-1
    else:
      x=bisect.bisect_left(dp,a)
      this=x
      dp[x]=a
    ansl.append(this)
  return ansl

N=int(input())
P=list(map(int,input().split()))
L=LIS(P)
this=0
K=list()
K2=list()
for i in range(len(L)):
  if L[i]==this:
    K.append(i)
    this+=1
this=max(L)
for i in range(len(L)-1,-1,-1):
  if L[i]==this:
    K2.append(i)
    this-=1
K2=set(K2)
ansl=list()
for i in K:
  if i in K2:
    ansl.append(P[i])
print(len(ansl))
print(*ansl)
0