結果
問題 | No.2856 Junk Market Game |
ユーザー |
![]() |
提出日時 | 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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
n = int(input())a = list(map(int,input().split()))b = list(map(int,input().split()))used = [0] * 2*nt = [(-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 = 0pivt = 0pivf = 0for i in range(n):while pivt < 2*n and used[t[pivt][1]]:pivt += 1used[t[pivt][1]] = 1x += a[t[pivt][1]]while pivf < 2*n and used[f[pivf][1]]:pivf += 1used[f[pivf][1]] = 1x -= b[f[pivf][1]]print(x)