結果

問題 No.2856 Junk Market Game
コンテスト
ユーザー shobonvip
提出日時 2024-08-25 14:08:33
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 77 ms / 2,000 ms
+ 930µs
コード長 467 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 273 ms
コンパイル使用メモリ 96,228 KB
実行使用メモリ 84,096 KB
最終ジャッジ日時 2026-08-25 06:08:22
合計ジャッジ時間 6,682 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
used = [0] * 2*n

t = [(-a[i]-b[i],i) for i in range(2*n)]
t.sort()
t=t[::-1]

f = [(-b[i]-a[i],i) for i in range(2*n)]
f.sort()
f=f[::-1]

x = 0
pivt = 0
pivf = 0
for i in range(n):
	while pivt < 2*n and used[t[pivt][1]]:
		pivt += 1
	used[t[pivt][1]] = 1
	x += a[t[pivt][1]]

	while pivf < 2*n and used[f[pivf][1]]:
		pivf += 1
	used[f[pivf][1]] = 1
	x -= b[f[pivf][1]]
print(x)
0