結果
問題 |
No.200 カードファイト!
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:50:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,765 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 81,900 KB |
実行使用メモリ | 54,160 KB |
最終ジャッジ日時 | 2025-06-12 19:50:38 |
合計ジャッジ時間 | 2,400 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 8 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 A_size = int(input[ptr]) ptr += 1 A_cards = list(map(int, input[ptr:ptr+A_size])) ptr += A_size C_size = int(input[ptr]) ptr += 1 C_cards = list(map(int, input[ptr:ptr+C_size])) ptr += C_size A_hand = sorted(A_cards) A_played = [] C_hand = sorted(C_cards) C_played = [] wins = 0 for _ in range(N): # Check if A's hand is empty, collect played if not A_hand: A_hand.extend(A_played) A_hand.sort() A_played = [] # Check if C's hand is empty, collect played if not C_hand: C_hand.extend(C_played) C_hand.sort() C_played = [] # Get the smallest c c = C_hand[0] # Find the smallest a in A_hand > c idx = bisect.bisect_right(A_hand, c) if idx < len(A_hand): a = A_hand[idx] # Remove a from A_hand A_hand.pop(idx) # Remove c from C_hand C_hand.pop(0) # Add to played A_played.append(a) C_played.append(c) wins += 1 else: # No a > c, take smallest a and c a = A_hand.pop(0) c = C_hand.pop(0) A_played.append(a) C_played.append(c) # After this round, check if hands are empty if not A_hand: A_hand.extend(A_played) A_hand.sort() A_played = [] if not C_hand: C_hand.extend(C_played) C_hand.sort() C_played = [] print(wins) if __name__ == '__main__': main()