結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-15 22:38:32 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 753 bytes |
| コンパイル時間 | 1,055 ms |
| コンパイル使用メモリ | 127,952 KB |
| 実行使用メモリ | 28,060 KB |
| 最終ジャッジ日時 | 2024-06-13 04:16:00 |
| 合計ジャッジ時間 | 2,615 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
auto N = readln.chomp.to!int;
auto AB = N.iota.map!(_ => readln.split.map!(to!long).array).array;
AB.sort!"a[1] > b[1]";
int buy = N - N / 3;
auto dp = new long[][](N+1, buy+1);
foreach (i; 0..N+1) dp[i][] = 1L << 59;
dp[0][0] = 0;
foreach (i; 0..N) {
foreach (j; 0..buy+1) {
if (j < buy) {
dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + AB[i][0] + AB[i][1] * j);
}
dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
}
}
dp[N][buy].writeln;
}