結果

問題 No.70 睡眠の重要性!
ユーザー harhogefooharhogefoo
提出日時 2016-10-06 08:51:48
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-05-01 13:22:45
合計ジャッジ時間 1,058 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,160 KB
testcase_01 AC 88 ms
12,288 KB
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 85 ms
12,288 KB
testcase_04 AC 84 ms
12,288 KB
testcase_05 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i


total_sleep_h, total_sleep_m = 0, 0
n.times do
  sleep, wakeup = gets.chomp.split(" ")
  sleep_h, sleep_m = sleep.chomp.split(":").map(&:to_i)
  wakeup_h, wakeup_m = wakeup.chomp.split(":").map(&:to_i)

  if sleep_h > wakeup_h
    sleep_h = 23 - sleep_h
    sleep_m = 60 - sleep_m

    sleep_h += wakeup_h
    sleep_m += wakeup_m
  else
    sleep_h = sleep_h + 1
    sleep_m = 60 - sleep_m

    sleep_h = wakeup_h - sleep_h
    sleep_m += wakeup_m
  end
  total_sleep_h += sleep_h
  total_sleep_m += sleep_m
end

puts "#{total_sleep_h * 60 + total_sleep_m}"
0