結果

問題 No.1188 レベルX門松列
ユーザー tyawanmusityawanmusi
提出日時 2020-08-22 17:56:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 433 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 19,856 KB
最終ジャッジ日時 2023-08-05 14:42:51
合計ジャッジ時間 6,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 384 ms
15,136 KB
testcase_01 AC 350 ms
17,192 KB
testcase_02 AC 312 ms
16,912 KB
testcase_03 AC 433 ms
19,716 KB
testcase_04 AC 427 ms
19,856 KB
testcase_05 AC 14 ms
8,132 KB
testcase_06 AC 369 ms
11,284 KB
testcase_07 AC 412 ms
19,792 KB
testcase_08 AC 417 ms
19,740 KB
testcase_09 AC 14 ms
8,148 KB
testcase_10 AC 14 ms
8,012 KB
testcase_11 AC 41 ms
9,244 KB
testcase_12 AC 45 ms
9,436 KB
testcase_13 AC 46 ms
9,388 KB
testcase_14 AC 244 ms
15,064 KB
testcase_15 AC 418 ms
18,852 KB
testcase_16 AC 19 ms
8,004 KB
testcase_17 AC 328 ms
16,544 KB
testcase_18 AC 13 ms
8,008 KB
testcase_19 AC 306 ms
15,972 KB
testcase_20 AC 14 ms
8,008 KB
testcase_21 AC 15 ms
7,976 KB
testcase_22 AC 13 ms
7,948 KB
testcase_23 AC 14 ms
8,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
def solve(n,a):
  ans=0
  dp_back=[10**20]*n
  b=[]
  for i in a[::-1]:
    dp_back[bisect_left(dp_back,i)]=i
    b.append(bisect_left(dp_back,10**20))
  b=b[::-1]
  dp=[10**20]*n
  for i in range(n):
    dp[bisect_left(dp,a[i])]=a[i]
    ans=max(ans,min(b[i],bisect_left(dp,10**20)))
  return ans
n=int(input())
a=list(map(int,input().split()))
ans=solve(n,a)
for i in range(n):a[i]*=-1
ans=max(ans,solve(n,a))
print(ans-1)
0