結果
| 問題 |
No.200 カードファイト!
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-31 17:54:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,338 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 82,752 KB |
| 実行使用メモリ | 54,728 KB |
| 最終ジャッジ日時 | 2025-03-31 17:55:56 |
| 合計ジャッジ時間 | 2,389 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 8 |
ソースコード
import bisect
n = int(input())
a = int(input())
b_list = list(map(int, input().split()))
c = int(input())
d_list = list(map(int, input().split()))
original_A = sorted(b_list)
original_C = sorted(d_list)
current_A = []
current_C = []
wins = 0
for _ in range(n):
# Refill if current cards are exhausted
if not current_A:
current_A = list(original_A)
if not current_C:
current_C = list(original_C)
sorted_A = sorted(current_A)
sorted_C = sorted(current_C)
found = False
chosen_d = None
chosen_a = None
# Find the smallest d in C that can be beaten by some a in A
for d in sorted_C:
idx = bisect.bisect_right(sorted_A, d)
if idx < len(sorted_A):
chosen_d = d
chosen_a = sorted_A[idx]
found = True
break
if found:
wins += 1
current_A.remove(chosen_a)
current_C.remove(chosen_d)
else:
# Remove smallest d and smallest a as they can't contribute to future wins
# Since any pair will not result in a win, we just remove the smallest ones
if sorted_C and sorted_A:
current_A.remove(sorted_A[0])
current_C.remove(sorted_C[0])
else:
# This case should not occur due to refilling logic
pass
print(wins)
lam6er