Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active January 29, 2017 02:15
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/a0830814875b09499e6670300abcd4d9 to your computer and use it in GitHub Desktop.
Save whatalnk/a0830814875b09499e6670300abcd4d9 to your computer and use it in GitHub Desktop.
AtCoder ABC #053 [Ruby]
x = gets.chomp.to_i
if x < 1200 then
puts "ABC"
else
puts "ARC"
end
s = gets.chomp
a = s.index("A")
z = s.rindex("Z")
puts z - a + 1
# AC
n = gets.chomp.to_i
h = Hash.new(0)
gets.chomp.split(" ").each do |a|
h[a.to_i] += 1
end
n_even = 0
n_odd = 0
h.each do |k, v|
if v.even? then
n_even += 1
else
n_odd += 1
end
end
if n_even.even? then
puts n_odd + n_even
else
puts n_odd + n_even - 1
end
x = gets.chomp.to_i
d = x / 11
r = x % 11
if r == 0 then
puts d * 2
elsif r < 7 then
puts d * 2 + 1
else
puts (d + 1) * 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment