結果

問題 No.1804 Intersection of LIS
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-09-20 02:46:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,018 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 113,424 KB
最終ジャッジ日時 2024-04-26 18:16:13
合計ジャッジ時間 5,165 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,016 KB
testcase_01 AC 41 ms
54,016 KB
testcase_02 AC 42 ms
54,016 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 42 ms
54,144 KB
testcase_29 AC 48 ms
61,440 KB
testcase_30 AC 41 ms
54,144 KB
testcase_31 AC 43 ms
54,016 KB
testcase_32 AC 57 ms
65,280 KB
testcase_33 AC 44 ms
53,888 KB
testcase_34 AC 51 ms
61,312 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
INF = 10 ** 9
def lis(x):
    dp = [INF] * (len(x) + 1)
    id = [0] * len(x)
    for i in range(len(x)):
        id[i] = bisect_left(dp, x[i])
        dp[bisect_left(dp, x[i])] = x[i]
    m = max(id)
    b = [0] * (m + 1)
    for i in range(len(x) - 1, -1, -1):
        if id[i] == m:
            b[m] = x[i]
            m -= 1
    return bisect_left(dp, INF), b
def lds(x):
    dp = [-INF] * (len(x) + 1)
    id = [0] * len(x)
    for i in range(len(x)):
        id[i] = bisect_left(dp, x[i]) - 1
        dp[bisect_left(dp, x[i]) - 1] = x[i]
    m = min(id)
    b = [0] * (max(id) + 1)
    for i in range(len(x))[::-1]:
        if id[i] == m:
            b[m] = x[i]
            m += 1
    return dp[::-1].index(-INF), b

import random
n = int(input())
p = list(map(int, input().split()))
if n > 2000: exit()
leng, lis1 = lis(p)
ans = []
cur = 0
for i in range(n):
    a2 = p[:i] + p[i + 1:]
    new_leng, _ = lis(a2)
    if leng != new_leng:
        ans.append(p[i])
print(len(ans))
print(*ans)
0