結果

問題 No.110 しましまピラミッド
ユーザー nanaenanae
提出日時 2017-03-19 14:59:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 1,345 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 8,376 KB
最終ジャッジ日時 2023-08-30 03:58:49
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,364 KB
testcase_01 AC 17 ms
8,292 KB
testcase_02 AC 16 ms
8,248 KB
testcase_03 AC 16 ms
8,268 KB
testcase_04 AC 16 ms
8,204 KB
testcase_05 AC 16 ms
8,232 KB
testcase_06 AC 16 ms
8,340 KB
testcase_07 AC 16 ms
8,236 KB
testcase_08 AC 16 ms
8,172 KB
testcase_09 AC 16 ms
8,280 KB
testcase_10 AC 16 ms
8,292 KB
testcase_11 AC 16 ms
8,196 KB
testcase_12 AC 16 ms
8,376 KB
testcase_13 AC 16 ms
8,332 KB
testcase_14 AC 16 ms
8,268 KB
testcase_15 AC 15 ms
8,196 KB
testcase_16 AC 15 ms
8,192 KB
testcase_17 AC 16 ms
8,236 KB
testcase_18 AC 16 ms
8,204 KB
testcase_19 AC 16 ms
8,336 KB
testcase_20 AC 16 ms
8,352 KB
testcase_21 AC 16 ms
8,340 KB
testcase_22 AC 15 ms
8,252 KB
testcase_23 AC 15 ms
8,296 KB
testcase_24 AC 16 ms
8,332 KB
testcase_25 AC 16 ms
8,332 KB
testcase_26 AC 16 ms
8,196 KB
testcase_27 AC 16 ms
8,172 KB
testcase_28 AC 16 ms
8,196 KB
testcase_29 AC 16 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Nw = int(input())
W = [int(i) for i in input().split()]
Nb = int(input())
B = [int(i) for i in input().split()]

W.sort(reverse=True)
B.sort(reverse=True)

ans = 1

tmp = 1
max_l = W[0]
flag = True
switch = 1
lw, lb = 0, 0

while flag:
    if switch == 0:
        for i in range(lw, Nw):
            if W[i] < max_l:
                max_l = W[i]
                switch ^= 1
                tmp += 1
                lw = i + 1
                break
        else:
            flag = False
    else:
        for i in range(lb, Nb):
            if B[i] < max_l:
                max_l = B[i]
                switch ^= 1
                tmp += 1
                lb = i + 1
                break
        else:
            flag = False

ans = max(ans, tmp)

max_l = B[0]
flag = True
switch = 0
lw, lb = 0, 0
tmp = 1

while flag:
    if switch == 0:
        for i in range(lw, Nw):
            if W[i] < max_l:
                max_l = W[i]
                switch ^= 1
                tmp += 1
                lw = i + 1
                break
        else:
            flag = False
    else:
        for i in range(lb, Nb):
            if B[i] < max_l:
                max_l = B[i]
                switch ^= 1
                tmp += 1
                lb = i + 1
                break
        else:
            flag = False

ans = max(ans, tmp)

print(ans)
0