Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
AtCoder ARC #047
n, l = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
tab_open = 1
n_crash = 0
s.each do |i|
if i == "+" then
tab_open += 1
else
tab_open -= 1 if tab_open > 1
end
if tab_open > l then
n_crash += 1
tab_open = 1
end
end
puts n_crash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment