Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created September 2, 2017 14:18
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/6f26d360c40f0522b9260f6e09231360 to your computer and use it in GitHub Desktop.
Save whatalnk/6f26d360c40f0522b9260f6e09231360 to your computer and use it in GitHub Desktop.
AtCoder ARC #082 / ABC #072
a, b = gets.chomp.split(" ").map(&:to_i)
puts [0, a - b].max
s = gets.chomp.split("")
n = s.length
ret = []
n.times do |i|
if (i + 1).odd?
ret << s[i]
end
end
puts ret.join("")
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = Array.new(10**5+1, 0)
a.each do |i|
b[i] += 1
end
ret = 0
b.each_cons(3) do |v1, v2, v3|
ret = [ret, v1 + v2 + v3].max
end
puts ret
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
ret = 0
curr = 1
i = 0
loop do
break if i > n - 1
if a[i] == curr
ret += 1
curr += 2
i += 2
else
curr += 1
i += 1
end
end
puts ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment