Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 17, 2018 14:47
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 whatalnk/9613bedd4d70d31d0e8e9b824fb76b42 to your computer and use it in GitHub Desktop.
Save whatalnk/9613bedd4d70d31d0e8e9b824fb76b42 to your computer and use it in GitHub Desktop.
AtCoder ABC #047 D
# ABC047 D
n, t = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
amin = a[0]
bmax = a[1] - a[0]
(n - 1).times do |i|
amin = [amin, a[i]].min
b = a[i+1] - amin
bmax = [b, bmax].max
h[b] += 1 if b > 0
end
puts h[bmax]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment