Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created October 14, 2017 06:27
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/f7c43ad96dd02afec13da996c160cf68 to your computer and use it in GitHub Desktop.
Save whatalnk/f7c43ad96dd02afec13da996c160cf68 to your computer and use it in GitHub Desktop.
AtCoder ARC #040 B - 直線塗り
N, R = gets.chomp.split(" ").map(&:to_i)
field = gets.chomp.split("")
i = field.rindex(".")
if i.nil?
puts 0
exit
else
ans = [i + 1 - R, 0].max
end
i = 0
while true
break if i > (N - 1)
if field[i] == "."
i += (R - 1)
ans += 1
end
i += 1
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment