結果
問題 | No.2856 Junk Market Game |
ユーザー | shobonvip |
提出日時 | 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*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)