結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-26 14:47:20 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 5,000 ms |
| コード長 | 839 bytes |
| コンパイル時間 | 478 ms |
| コンパイル使用メモリ | 7,040 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 11:24:40 |
| 合計ジャッジ時間 | 1,429 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
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]:
a = W.pop()
B.pop()
ans += 1
if last == 'B':
last = 'W'
elif last == 'W':
last = 'B'
elif W[-1] > B[-1]:
a = W.pop()
if last == 'B':
ans += 1
last = 'W'
else:
a = 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'))