Created
February 18, 2018 15:30
-
-
Save whatalnk/47b8ef9500a89c4fdb13b7553b3ce0b9 to your computer and use it in GitHub Desktop.
Hack to the Future 2018 Qual
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
n = 100 | |
a = [] | |
100.times do | |
r = gets.chomp.split(" ").map(&:to_i) | |
a += r | |
end | |
ret = [] | |
1000.times do | |
amax = a.max | |
h = [n, amax].min | |
break if h == 0 | |
i = a.index(amax) | |
y = i / n | |
x = i - (n * y) | |
n.times do |yy| | |
n.times do |xx| | |
a[yy * n + xx] -= [0, h - (xx - x).abs - (yy - y).abs].max | |
end | |
end | |
ret << "#{x} #{y} #{h}" | |
end | |
puts ret.size | |
ret.each do |l| | |
puts l | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment