結果

問題 No.2856 Junk Market Game
ユーザー shobonvipshobonvip
提出日時 2024-08-25 14:08:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 70,260 KB
最終ジャッジ日時 2024-08-25 14:08:38
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,284 KB
testcase_01 AC 34 ms
52,940 KB
testcase_02 AC 34 ms
53,604 KB
testcase_03 AC 34 ms
52,960 KB
testcase_04 AC 34 ms
53,368 KB
testcase_05 AC 34 ms
52,232 KB
testcase_06 AC 34 ms
52,500 KB
testcase_07 AC 35 ms
52,068 KB
testcase_08 AC 34 ms
52,544 KB
testcase_09 AC 35 ms
53,668 KB
testcase_10 AC 42 ms
62,764 KB
testcase_11 AC 51 ms
68,232 KB
testcase_12 AC 55 ms
69,396 KB
testcase_13 AC 41 ms
61,972 KB
testcase_14 AC 50 ms
68,256 KB
testcase_15 AC 43 ms
61,520 KB
testcase_16 AC 62 ms
67,668 KB
testcase_17 AC 48 ms
64,832 KB
testcase_18 AC 47 ms
66,508 KB
testcase_19 AC 52 ms
65,572 KB
testcase_20 AC 41 ms
62,760 KB
testcase_21 AC 52 ms
69,456 KB
testcase_22 AC 52 ms
68,440 KB
testcase_23 AC 48 ms
65,708 KB
testcase_24 AC 51 ms
67,788 KB
testcase_25 AC 42 ms
61,352 KB
testcase_26 AC 38 ms
52,732 KB
testcase_27 AC 57 ms
67,392 KB
testcase_28 AC 48 ms
64,304 KB
testcase_29 AC 55 ms
68,668 KB
testcase_30 AC 55 ms
69,124 KB
testcase_31 AC 55 ms
69,484 KB
testcase_32 AC 53 ms
68,556 KB
testcase_33 AC 54 ms
68,680 KB
testcase_34 AC 58 ms
69,272 KB
testcase_35 AC 53 ms
69,348 KB
testcase_36 AC 54 ms
70,260 KB
testcase_37 AC 54 ms
68,700 KB
testcase_38 AC 55 ms
69,076 KB
testcase_39 AC 53 ms
69,092 KB
testcase_40 AC 54 ms
69,524 KB
testcase_41 AC 59 ms
69,496 KB
testcase_42 AC 55 ms
69,016 KB
testcase_43 AC 56 ms
69,420 KB
testcase_44 AC 52 ms
69,172 KB
testcase_45 AC 55 ms
69,912 KB
testcase_46 AC 55 ms
69,852 KB
testcase_47 AC 56 ms
69,320 KB
testcase_48 AC 58 ms
69,120 KB
testcase_49 AC 55 ms
69,576 KB
testcase_50 AC 49 ms
64,872 KB
testcase_51 AC 49 ms
65,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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