結果

問題 No.200 カードファイト!
コンテスト
ユーザー titia
提出日時 2025-12-31 05:45:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 862 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 429 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 58,824 KB
最終ジャッジ日時 2025-12-31 05:45:47
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N=int(input())
x=int(input())
A0=list(map(int,input().split()))
y=int(input())
B0=list(map(int,input().split()))

length=0

A=[]
B=[]
ANS=0

while length<N:
    if A==[]:
        A=A0[:]
    if B==[]:
        B=B0[:]

    A.sort(reverse=True)
    B.sort()

    
    A=A[:N-length]
    B=B[:N-length]
        
    if len(A)<=len(B):
        ind=-1
        for i in range(len(B)):
            if A[0]>B[i]:
                ind=i

        if ind==-1:
            B.pop()
        else:
            ANS+=1
            B.pop(ind)
        A.pop(0)
    else:
        ind=-1
        for i in range(len(A)):
            if A[i]>B[0]:
                ind=i

        if ind==-1:
            A.pop()
        else:
            ANS+=1
            A.pop(ind)
        B.pop(0)
    length+=1

print(ANS)
        

        
        
        
0