結果

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

テストケース

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

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.buffer.readline
    from bisect import bisect_left
    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)
if __name__ == '__main__':
    main()
    
0