結果

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

ソースコード

diff #

from bisect import bisect_left
from itertools import count


def main():
    _ = int(input())
    W = list(map(int, input().split()))
    _ = int(input())
    B = list(map(int, input().split()))

    W.sort()
    B.sort()

    W_start_tower = [W[0]]
    B_start_tower = [B[0]]

    for idx in range(40):
        match idx % 2:
            case 0:
                B_idx = bisect_left(B, W_start_tower[-1]+1)
                if B_idx != len(B):
                    W_start_tower.append(B[B_idx])
                else:
                    break

            case 1:
                W_idx = bisect_left(W, W_start_tower[-1]+1)
                if W_idx != len(W):
                    W_start_tower.append(W[W_idx])
                else:
                    break

    for idx in range(40):
        match idx % 2:
            case 0:

                W_idx = bisect_left(W, B_start_tower[-1]+1)
                if W_idx != len(W):
                    B_start_tower.append(W[W_idx])
                else:
                    break

            case 1:
                B_idx = bisect_left(B, B_start_tower[-1]+1)
                if B_idx != len(B):
                    B_start_tower.append(B[B_idx])
                else:
                    break

    print(max(len(W_start_tower), len(B_start_tower)))


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