結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 400 ms
17,676 KB
testcase_01 AC 361 ms
19,320 KB
testcase_02 AC 327 ms
18,804 KB
testcase_03 AC 437 ms
21,544 KB
testcase_04 AC 448 ms
20,780 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 383 ms
14,036 KB
testcase_07 AC 439 ms
20,780 KB
testcase_08 AC 435 ms
20,780 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 57 ms
11,776 KB
testcase_12 AC 60 ms
11,776 KB
testcase_13 AC 62 ms
11,904 KB
testcase_14 AC 259 ms
17,264 KB
testcase_15 AC 429 ms
21,612 KB
testcase_16 AC 35 ms
10,880 KB
testcase_17 AC 340 ms
19,232 KB
testcase_18 AC 30 ms
10,752 KB
testcase_19 AC 320 ms
18,760 KB
testcase_20 AC 31 ms
10,752 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 30 ms
10,752 KB
testcase_23 AC 31 ms
10,752 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