結果

問題 No.561 東京と京都
ユーザー ueyukiueyuki
提出日時 2017-09-14 23:23:09
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 283 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-25 10:26:20
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 91 ms
12,288 KB
testcase_02 AC 91 ms
12,160 KB
testcase_03 AC 90 ms
12,160 KB
testcase_04 WA -
testcase_05 AC 90 ms
12,160 KB
testcase_06 AC 92 ms
12,416 KB
testcase_07 AC 90 ms
12,160 KB
testcase_08 AC 89 ms
12,288 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 88 ms
12,288 KB
testcase_13 AC 91 ms
12,032 KB
testcase_14 AC 92 ms
12,160 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,d = gets.chomp.split.map(&:to_i)
location = 't'
income = 0

n.times do
  t,k = gets.chomp.split.map(&:to_i)
  if location == 't'
    k = k - d
  else
    t = t - d
  end

  if t > k
    income += t
    location = 't'
  else
    income += k
    location = 'k'
  end
end

puts income
0