結果

問題 No.110 しましまピラミッド
ユーザー vwxyz
提出日時 2022-10-18 11:16:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-28 20:11:14
合計ジャッジ時間 1,908 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
W=list(map(int,readline().split()))
M=int(readline())
B=list(map(int,readline().split()))
W.sort()
B.sort()
ans=0
for i in range(2):
    lst=[]
    WB=[[w for w in W],[b for b in B]]
    for j in range(100):
        ij=(i+j)%2
        while WB[ij] and lst and WB[ij][-1]>=lst[-1]:
            WB[ij].pop()
        if WB[ij] and (not lst or WB[ij][-1]<lst[-1]):
            lst.append(WB[ij].pop())
        else:
            break
    ans=max(ans,len(lst))
print(ans)
0