結果
| 問題 |
No.2856 Junk Market Game
|
| コンテスト | |
| ユーザー |
prd_xxx
|
| 提出日時 | 2024-08-25 15:03:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 722 bytes |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 82,224 KB |
| 実行使用メモリ | 76,652 KB |
| 最終ジャッジ日時 | 2024-08-25 15:03:18 |
| 合計ジャッジ時間 | 5,246 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
ソースコード
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
AB = [(a,b) for a,b in zip(A,B)]
AB.sort(key=lambda x: x[0]+x[1])
NN = N+N
INF = 10**18
dp = [-b for a,b in AB]
for l in range(1,NN):
if l%2:
ndp = [INF] * (NN-l)
else:
ndp = [-INF] * (NN-l)
for i in range(NN-l):
if l%2:
if i+1 < len(dp):
ndp[i] = min(ndp[i], dp[i+1] + AB[i][0])
if i+l < NN:
ndp[i] = min(ndp[i], dp[i] + AB[i+l][0])
else:
if i+1 < len(dp):
ndp[i] = max(ndp[i], dp[i+1] - AB[i][1])
if i+l < NN:
ndp[i] = max(ndp[i], dp[i] - AB[i+l][1])
dp = ndp
print(dp[0])
prd_xxx