목차

Leave Out All The Rest

ps
링크acmicpc.net/…
출처BOJ
문제 번호19086
문제명Leave Out All The Rest
레벨골드 1
분류

LIS

시간복잡도O(nlogn + mlogm)
인풋사이즈n<=500,000, m<=500,000
사용한 언어Python 3.13
제출기록114804KB / 524ms
최고기록524ms
해결날짜2026/01/19

풀이

코드

"""Solution code for "BOJ 19086. Leave Out All The Rest".

- Problem link: https://www.acmicpc.net/problem/19086
- Solution link: http://www.teferi.net/ps/problems/boj/19086

Tags: [lis]
"""

from teflib import seqtask


def main():
    _n = int(input())
    a = [int(x) for x in input().split()]
    _m = int(input())
    b = [int(x) for x in input().split()]

    lis_len_a = seqtask.longest_inc_subseq_length(a)
    lis_len_b = seqtask.longest_inc_subseq_length(b)

    print(lis_len_a + lis_len_b)


if __name__ == '__main__':
    main()