結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-14 17:41:10 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 5,000 ms |
| コード長 | 566 bytes |
| コンパイル時間 | 38 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-07-21 07:44:18 |
| 合計ジャッジ時間 | 1,262 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
コンパイルメッセージ
Syntax OK
ソースコード
#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
N = gets.to_i
total_sleep = 0
N.times do
=begin
# 正規表現
m = /(?<h1>\d+):(?<m1>\d+) (?<h2>\d+):(?<m2>\d+)/.match(gets)
t1 = m[:h1].to_i * 60 + m[:m1].to_i
t2 = m[:h2].to_i * 60 + m[:m2].to_i
=end
=begin
(h1,m1),(h2,m2)=gets.chomp.split.map{|x|x.split(':').map(&:to_i)}
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2
=end
# もっと簡潔に
t1, t2=gets.chomp.split.map{|x|x.split(':').map(&:to_i)}.map{|h,m|h*60+m}
total_sleep += t2 - t1 + (t2 < t1 ? 24 * 60 : 0)
end
puts total_sleep