結果

問題 No.110 しましまピラミッド
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-27 19:33:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 1,216 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 71,764 KB
最終ジャッジ日時 2023-09-07 02:45:57
合計ジャッジ時間 5,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,736 KB
testcase_01 AC 92 ms
71,532 KB
testcase_02 AC 81 ms
71,704 KB
testcase_03 AC 81 ms
71,360 KB
testcase_04 AC 82 ms
71,752 KB
testcase_05 AC 83 ms
71,600 KB
testcase_06 AC 82 ms
71,596 KB
testcase_07 AC 82 ms
71,408 KB
testcase_08 AC 82 ms
71,476 KB
testcase_09 AC 85 ms
71,336 KB
testcase_10 AC 84 ms
71,588 KB
testcase_11 AC 85 ms
71,500 KB
testcase_12 AC 83 ms
71,756 KB
testcase_13 AC 83 ms
71,704 KB
testcase_14 AC 82 ms
71,612 KB
testcase_15 AC 82 ms
71,516 KB
testcase_16 AC 82 ms
71,536 KB
testcase_17 AC 83 ms
71,704 KB
testcase_18 AC 86 ms
71,732 KB
testcase_19 AC 85 ms
71,396 KB
testcase_20 AC 83 ms
71,400 KB
testcase_21 AC 84 ms
71,728 KB
testcase_22 AC 83 ms
71,664 KB
testcase_23 AC 83 ms
71,572 KB
testcase_24 AC 84 ms
71,592 KB
testcase_25 AC 86 ms
71,764 KB
testcase_26 AC 82 ms
71,640 KB
testcase_27 AC 82 ms
71,524 KB
testcase_28 AC 88 ms
71,760 KB
testcase_29 AC 84 ms
71,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

nw = int(input())
W = list(map(int, input().split()))
nb = int(input())
B = list(map(int, input().split()))

import copy
W_ = copy.copy(W)
B_ = copy.copy(B)

W_.sort()
B_.sort()

# W > B
cur = W_.pop()
cnt1 = 1
while True:
    if cnt1%2 == 1:
        while B_:
            if B_[-1] >= cur:
                B_.pop()
            else:
                cur = B_.pop()
                cnt1 += 1
                break
        else:
            break
    else:
        while W_:
            if W_[-1] >= cur:
                W_.pop()
            else:
                cur = W_.pop()
                cnt1 += 1
                break
        else:
            break
W_ = copy.copy(W)
B_ = copy.copy(B)

W_.sort()
B_.sort()

# B > W
cur = B_.pop()
cnt2 = 1
while True:
    if cnt2%2 == 1:
        while W_:
            if W_[-1] >= cur:
                W_.pop()
            else:
                cur = W_.pop()
                cnt2 += 1
                break
        else:
            break
    else:
        while B_:
            if B_[-1] >= cur:
                B_.pop()
            else:
                cur = B_.pop()
                cnt2 += 1
                break
        else:
            break
print(max(cnt1, cnt2))
0