結果

問題 No.110 しましまピラミッド
ユーザー lloyzlloyz
提出日時 2023-07-03 22:37:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 1,189 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 71,584 KB
最終ジャッジ日時 2023-09-24 19:51:33
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,408 KB
testcase_01 AC 69 ms
71,320 KB
testcase_02 AC 69 ms
71,328 KB
testcase_03 AC 67 ms
71,404 KB
testcase_04 AC 67 ms
71,448 KB
testcase_05 AC 70 ms
71,388 KB
testcase_06 AC 69 ms
71,352 KB
testcase_07 AC 66 ms
71,528 KB
testcase_08 AC 66 ms
71,404 KB
testcase_09 AC 69 ms
71,236 KB
testcase_10 AC 71 ms
71,100 KB
testcase_11 AC 65 ms
71,348 KB
testcase_12 AC 69 ms
71,300 KB
testcase_13 AC 70 ms
71,276 KB
testcase_14 AC 70 ms
71,148 KB
testcase_15 AC 70 ms
71,300 KB
testcase_16 AC 70 ms
71,260 KB
testcase_17 AC 72 ms
71,256 KB
testcase_18 AC 68 ms
71,348 KB
testcase_19 AC 67 ms
71,344 KB
testcase_20 AC 69 ms
71,416 KB
testcase_21 AC 71 ms
71,556 KB
testcase_22 AC 70 ms
71,544 KB
testcase_23 AC 68 ms
71,300 KB
testcase_24 AC 70 ms
71,096 KB
testcase_25 AC 70 ms
71,304 KB
testcase_26 AC 69 ms
71,584 KB
testcase_27 AC 69 ms
71,360 KB
testcase_28 AC 70 ms
71,512 KB
testcase_29 AC 70 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

W.sort(reverse=True)
B.sort(reverse=True)
Wc = W[:]
Bc = B[:]

res = 1
l = W[0]
iw, ib = 1, 0
white = False
while True:
    if white:
        while iw < nw:
            ll = W[iw]
            if ll < l:
                break
            iw += 1
        if iw == nw:
            break
        l = ll
        res += 1
        white = False
    else:
        while ib < nb:
            ll = B[ib]
            if ll < l:
                break
            ib += 1
        if ib == nb:
            break
        l = ll
        res += 1
        white = True
ans = res

res = 1
l = B[0]
iw, ib = 0, 1
white = True
while True:
    if white:
        while iw < nw:
            ll = W[iw]
            if ll < l:
                break
            iw += 1
        if iw == nw:
            break
        l = ll
        res += 1
        white = False
    else:
        while ib < nb:
            ll = B[ib]
            if ll < l:
                break
            ib += 1
        if ib == nb:
            break
        l = ll
        res += 1
        white = True
ans = max(ans, res)
print(ans)
0