#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU N = gets.to_i total_sleep = 0 N.times do =begin # 正規表現 m = /(?

\d+):(?\d+) (?

\d+):(?\d+)/.match(gets) t1 = m[:h1].to_i * 60 + m[:m1].to_i t2 = m[:h2].to_i * 60 + m[:m2].to_i =end (h1,m1),(h2,m2)=gets.chomp.split.map{|x|x.split(':').map(&:to_i)} t1 = h1 * 60 + m1 t2 = h2 * 60 + m2 total_sleep += t2 - t1 + (t2 < t1 ? 24 * 60 : 0) end puts total_sleep