結果

問題 No.110 しましまピラミッド
ユーザー solzard
提出日時 2019-08-08 07:45:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 558 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-18 18:55:36
合計ジャッジ時間 1,846 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

# No.110 しましまピラミッド
def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    M = int(input())
    B = sorted(map(int, input().split()))
    lim = 20  # 1 ≤ A𝑖, B𝑖 ≤ 20
    # dp[current color][height] := optimum length
    dp = [[0] * (lim + 1) for _ in range(2)]
    for i in range(1, lim + 1):
        if i in A:
            dp[0][i] = max(dp[1][:i]) + 1
        if i in B:
            dp[1][i] = max(dp[0][:i]) + 1
    ans = max(max(dp[0]), max(dp[1]))
    print(ans)


if __name__ == "__main__":
    main()
0