結果

問題 No.561 東京と京都
ユーザー urutomurutom
提出日時 2019-04-04 17:06:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 190 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 11,368 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-08-26 21:27:43
合計ジャッジ時間 3,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
15,284 KB
testcase_01 AC 70 ms
15,152 KB
testcase_02 AC 68 ms
15,128 KB
testcase_03 AC 69 ms
15,304 KB
testcase_04 AC 70 ms
15,296 KB
testcase_05 AC 71 ms
15,136 KB
testcase_06 AC 75 ms
15,120 KB
testcase_07 AC 71 ms
15,128 KB
testcase_08 AC 69 ms
15,124 KB
testcase_09 AC 71 ms
15,252 KB
testcase_10 AC 69 ms
15,176 KB
testcase_11 AC 68 ms
15,284 KB
testcase_12 AC 73 ms
15,124 KB
testcase_13 AC 77 ms
15,176 KB
testcase_14 AC 73 ms
15,080 KB
testcase_15 AC 68 ms
15,076 KB
testcase_16 AC 71 ms
15,172 KB
testcase_17 AC 68 ms
15,340 KB
testcase_18 AC 70 ms
15,012 KB
testcase_19 AC 67 ms
15,080 KB
testcase_20 AC 70 ms
15,324 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,d=gets.split.map(&:to_i)
earns=n.times.map{gets.split.map(&:to_i)}

dp=[0,-d]
0.upto(n-1){|i|
  t,k=earns[i]
  _dp=[[dp[0]+t,dp[1]-d+t].max,[dp[0]-d+k,dp[1]+k].max]
  dp=_dp
}

puts dp.max
0