Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active January 20, 2016 07:34
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/ebb9092dfb039efe9d51 to your computer and use it in GitHub Desktop.
Save whatalnk/ebb9092dfb039efe9d51 to your computer and use it in GitHub Desktop.
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