結果

問題 No.1282 Display Elements
ユーザー uni_pythonuni_python
提出日時 2020-11-06 22:09:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 98,140 KB
最終ジャッジ日時 2023-09-29 18:50:33
合計ジャッジ時間 4,967 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,240 KB
testcase_01 AC 68 ms
71,044 KB
testcase_02 AC 72 ms
71,416 KB
testcase_03 AC 71 ms
71,392 KB
testcase_04 AC 70 ms
71,400 KB
testcase_05 AC 69 ms
71,244 KB
testcase_06 AC 68 ms
71,400 KB
testcase_07 AC 66 ms
71,396 KB
testcase_08 AC 66 ms
71,216 KB
testcase_09 AC 68 ms
71,300 KB
testcase_10 AC 85 ms
76,372 KB
testcase_11 AC 79 ms
76,288 KB
testcase_12 AC 70 ms
70,920 KB
testcase_13 AC 78 ms
75,732 KB
testcase_14 AC 89 ms
76,132 KB
testcase_15 AC 329 ms
96,240 KB
testcase_16 AC 204 ms
86,088 KB
testcase_17 AC 244 ms
94,812 KB
testcase_18 AC 258 ms
88,640 KB
testcase_19 AC 141 ms
97,036 KB
testcase_20 AC 110 ms
93,220 KB
testcase_21 AC 287 ms
98,104 KB
testcase_22 AC 258 ms
97,868 KB
testcase_23 AC 301 ms
98,140 KB
権限があれば一括ダウンロードができます

ソースコード

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