Last active
January 24, 2016 02:50
-
-
Save whatalnk/3e74415feaf7d211d00e to your computer and use it in GitHub Desktop.
Codeforces Round #340 Div2
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 = gets.chomp.to_i | |
a = n / 5 | |
b = n % 5 | |
if b == 0 then | |
puts a | |
else | |
puts a + 1 | |
end |
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 = gets.chomp.to_i | |
a = gets.chomp.split(" ").map(&:to_i) | |
nut = [] | |
a.each_with_index do |i, j| | |
if i == 1 then | |
nut << j | |
end | |
end | |
dnut = [] | |
(1..(nut.length - 1)).each do |i| | |
dnut << nut[i] - nut[i - 1] | |
end | |
if a.all?{|v| v == 0} then | |
puts 0 | |
elsif dnut.empty? then | |
puts 1 | |
else | |
puts dnut.inject(:*) | |
end |
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, x1, y1, x2, y2 = gets.chomp.split(" ").map(&:to_i) | |
dist = [] | |
n.times do | |
fx, fy = gets.chomp.split(" ").map(&:to_i) | |
d1 = (x1 - fx)**2 + (y1 - fy)**2 | |
d2 = (x2 - fx)**2 + (y2 - fy)**2 | |
dist << [d1, d2] | |
end | |
dist << [0,0] | |
res = Float::INFINITY | |
dist.each do |i| | |
r1 = i[0] | |
r2 = 0 | |
dist.each do |j| | |
if j[0] > r1 then | |
r2 = [r2, j[1]].max | |
end | |
end | |
res = [res, r1 + r2].min | |
end | |
puts res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment