結果

問題 No.1282 Display Elements
ユーザー uni_pythonuni_python
提出日時 2020-11-06 22:09:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 98,176 KB
最終ジャッジ日時 2024-07-22 12:54:36
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
大きいカードを後に出して損することがないかな
"""

N=I()
A=LI()
B=LI()+[10**10]

A.sort()

import heapq
hq=[10**10]
heapq.heapify(hq)

ans=0
for i in range(N):
    a=A[i]
    b=B[i]
    if b<a:
        ans+=N-i
    else:
        heapq.heappush(hq,b)
    
    while True:
        bb=heapq.heappop(hq)
        if bb<a:
            ans+=N-i
        else:
            heapq.heappush(hq,bb)
            break

    # print(i,a,b,ans)
        
print(ans)
    
    


0