Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created January 3, 2016 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/76734931ad36138113b0 to your computer and use it in GitHub Desktop.
Save chuck0523/76734931ad36138113b0 to your computer and use it in GitHub Desktop.
n, t = gets.chomp.split.map(&:to_i)
now = 0
close = 0
sum = 0
n.times do |i|
now = gets.to_i
sum += t
if close - now > 0
sum -= close - now
end
close = now + t
end
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment