結果
問題 | No.1804 Intersection of LIS |
ユーザー | NatsubiSogan |
提出日時 | 2021-09-20 02:48:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,304 bytes |
コンパイル時間 | 481 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 124,968 KB |
最終ジャッジ日時 | 2024-04-26 18:16:43 |
合計ジャッジ時間 | 6,559 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
59,904 KB |
testcase_01 | AC | 47 ms
53,888 KB |
testcase_02 | AC | 47 ms
54,144 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 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
ソースコード
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 > 5000: 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()