Created
September 17, 2018 14:47
-
-
Save whatalnk/9613bedd4d70d31d0e8e9b824fb76b42 to your computer and use it in GitHub Desktop.
AtCoder ABC #047 D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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