結果

問題 No.110 しましまピラミッド
ユーザー kohei2019kohei2019
提出日時 2021-06-02 21:23:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 1,021 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 55,360 KB
最終ジャッジ日時 2024-04-27 14:25:23
合計ジャッジ時間 2,570 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,636 KB
testcase_01 AC 38 ms
54,784 KB
testcase_02 AC 36 ms
55,360 KB
testcase_03 AC 37 ms
54,780 KB
testcase_04 AC 38 ms
53,764 KB
testcase_05 AC 40 ms
54,460 KB
testcase_06 AC 36 ms
54,912 KB
testcase_07 AC 39 ms
55,308 KB
testcase_08 AC 38 ms
54,524 KB
testcase_09 AC 37 ms
53,996 KB
testcase_10 AC 37 ms
53,796 KB
testcase_11 AC 38 ms
53,500 KB
testcase_12 AC 37 ms
54,368 KB
testcase_13 AC 38 ms
54,392 KB
testcase_14 AC 36 ms
55,248 KB
testcase_15 AC 38 ms
54,220 KB
testcase_16 AC 36 ms
54,020 KB
testcase_17 AC 39 ms
54,852 KB
testcase_18 AC 40 ms
54,548 KB
testcase_19 AC 37 ms
53,828 KB
testcase_20 AC 39 ms
53,428 KB
testcase_21 AC 37 ms
53,976 KB
testcase_22 AC 39 ms
54,180 KB
testcase_23 AC 40 ms
53,960 KB
testcase_24 AC 39 ms
53,808 KB
testcase_25 AC 38 ms
54,380 KB
testcase_26 AC 38 ms
54,980 KB
testcase_27 AC 37 ms
54,184 KB
testcase_28 AC 37 ms
53,964 KB
testcase_29 AC 37 ms
54,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
Na = int(input())
lsW1 = list(map(int,input().split()))
lsW1.sort()
lsW = copy.copy(lsW1)
Nb = int(input())
lsB1 = list(map(int,input().split()))
lsB1.sort()
lsB = copy.copy(lsB1)

cnt1 = 1
now = lsW.pop()
while True:
    if cnt1 % 2 == 1:
        if not lsB:
            break
        if now > lsB[-1]:
            cnt1 += 1
            now = lsB.pop()
        else:
            lsB.pop()
    if cnt1 % 2 == 0:
        if not lsW:
            break
        if now > lsW[-1]:
            cnt1 += 1
            now = lsW.pop()
        else:
            lsW.pop()

lsW = copy.copy(lsW1)
lsB = copy.copy(lsB1)
cnt2 = 1
now = lsB.pop()
while True:
    if cnt2 % 2 == 1:
        if not lsW:
            break
        if now > lsW[-1]:
            cnt2 += 1
            now = lsW.pop()
        else:
            lsW.pop()
    if cnt2 % 2 == 0:
        if not lsB:
            break
        if now > lsB[-1]:
            cnt2 += 1
            now = lsB.pop()
        else:
            lsB.pop()
print(max(cnt1,cnt2))
0