結果
| 問題 | No.200 カードファイト! |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:30:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,364 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,712 KB |
| 実行使用メモリ | 54,380 KB |
| 最終ジャッジ日時 | 2025-06-12 18:30:51 |
| 合計ジャッジ時間 | 2,097 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 12 |
ソースコード
import bisect
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx]); idx +=1
A = int(input[idx]); idx +=1
B = list(map(int, input[idx:idx+A]))
idx +=A
C = int(input[idx]); idx +=1
D = list(map(int, input[idx:idx+C]))
idx +=C
# Sort A's cards in ascending order for bisect
B_sorted = sorted(B)
# Generate C's card sequence: sorted, and repeated as per N and C's count
D_sorted = sorted(D)
c = len(D_sorted)
# Create the list of C's cards to be used in each match
base = N // c
remainder = N % c
c_sequence = []
for i in range(c):
count = base
if i < remainder:
count +=1
c_sequence.extend([D_sorted[i]] * count)
# Sort the sequence to have all smallest C's cards first
c_sequence.sort()
wins = 0
# For each card in C's sequence, find the smallest A's card that can beat it
for d in c_sequence:
# Find the first index in B_sorted where B > d
pos = bisect.bisect_right(B_sorted, d)
if pos < len(B_sorted):
wins +=1
# To avoid reusing the same card, but since cards can be reused, no need to remove
# However, in this problem, cards can be reused infinitely, so no need to track usage
print(wins)
if __name__ == "__main__":
main()
gew1fw