結果

問題 No.1188 レベルX門松列
ユーザー tyawanmusityawanmusi
提出日時 2020-08-22 17:56:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,656 KB
最終ジャッジ日時 2024-04-23 11:49:40
合計ジャッジ時間 6,813 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 403 ms
17,800 KB
testcase_01 AC 359 ms
19,320 KB
testcase_02 AC 326 ms
18,804 KB
testcase_03 AC 437 ms
21,552 KB
testcase_04 AC 447 ms
20,780 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 380 ms
14,040 KB
testcase_07 AC 435 ms
20,780 KB
testcase_08 AC 437 ms
20,908 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 58 ms
11,776 KB
testcase_12 AC 61 ms
11,776 KB
testcase_13 AC 61 ms
11,776 KB
testcase_14 AC 260 ms
17,260 KB
testcase_15 AC 432 ms
21,656 KB
testcase_16 AC 34 ms
11,008 KB
testcase_17 AC 343 ms
19,228 KB
testcase_18 AC 31 ms
10,880 KB
testcase_19 AC 319 ms
18,884 KB
testcase_20 AC 31 ms
10,880 KB
testcase_21 AC 30 ms
10,880 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 30 ms
10,880 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