結果

問題 No.110 しましまピラミッド
ユーザー nebukuro09
提出日時 2016-10-26 14:42:47
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-24 03:51:20
合計ジャッジ時間 1,202 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 22 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

Nw = input()
Ww = sorted(list(set(map(int, raw_input().split()))))
Nb = input()
Bb = sorted(list(set(map(int, raw_input().split()))))

def solve(last):
    ans = 0
    W = Ww[:]
    B = Bb[:]
    while len(W) > 0 and len(B) > 0:
        if W[-1] == B[-1]:
            W.pop()
            B.pop()
            ans += 1
            if last == 'B':
                last = 'W'
            elif last == 'W':
                last == 'B'
        elif W[-1] > B[-1]:
            W.pop()
            if last == 'B':
                ans += 1
                last = 'W'
        else:
            B.pop()
            if last == 'W':
                ans += 1
                last = 'B'
    if len(W) > 0 and last == 'B':
        ans += 1
    elif len(B) > 0 and last == 'W':
        ans += 1
    return ans

print max(solve('B'), solve('W'))
0