結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-07 08:28:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 551 ms / 2,000 ms |
| コード長 | 511 bytes |
| コンパイル時間 | 115 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,472 KB |
| 最終ジャッジ日時 | 2024-10-14 11:41:57 |
| 合計ジャッジ時間 | 15,699 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
# %%
N = int(readline())
AB = np.array(read().split(), np.int64)
A = AB[::2]
B = AB[1::2]
# %%
ind = np.argsort(B)[::-1]
A = A[ind]
B = B[ind]
# %%
K = (N * 2 + 2) // 3
INF = 10 ** 15
dp = np.full(K + 1, INF, np.int64)
dp[0] = 0
for a, b in zip(A, B):
np.minimum(dp[1:], dp[:-1] + (a + b * np.arange(K)), out=dp[1:])
# %%
print(dp[-1])
maspy