結果

問題 No.798 コレクション
ユーザー yuruhiyayuruhiya
提出日時 2020-08-09 16:50:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 968 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 42,112 KB
最終ジャッジ日時 2024-04-15 08:11:33
合計ジャッジ時間 9,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,288 KB
testcase_01 AC 89 ms
12,288 KB
testcase_02 AC 90 ms
12,160 KB
testcase_03 AC 91 ms
12,160 KB
testcase_04 AC 90 ms
12,160 KB
testcase_05 AC 91 ms
12,160 KB
testcase_06 AC 90 ms
12,288 KB
testcase_07 AC 89 ms
12,160 KB
testcase_08 AC 91 ms
12,288 KB
testcase_09 AC 92 ms
12,288 KB
testcase_10 AC 90 ms
12,160 KB
testcase_11 AC 90 ms
12,288 KB
testcase_12 AC 91 ms
12,288 KB
testcase_13 AC 444 ms
27,392 KB
testcase_14 AC 664 ms
40,704 KB
testcase_15 AC 582 ms
34,944 KB
testcase_16 AC 317 ms
24,064 KB
testcase_17 AC 451 ms
27,776 KB
testcase_18 AC 842 ms
36,864 KB
testcase_19 AC 696 ms
42,112 KB
testcase_20 AC 333 ms
24,320 KB
testcase_21 AC 298 ms
23,552 KB
testcase_22 AC 584 ms
34,688 KB
testcase_23 AC 90 ms
12,288 KB
testcase_24 AC 968 ms
34,816 KB
testcase_25 AC 893 ms
34,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = (1..n).map { gets.split.map &:to_i }.sort_by { -_2 }

I = 10**18
dp = [I] * (n + 1)
dp[0] = 0
(0...n).each do |t|
	dp =
		(0..n).map do |i|
			[dp[i] + a[t][0] + a[t][1] * (t - i), dp[i - 1] || I].min
		end
end
p dp[n / 3]
0