Created
October 14, 2017 06:27
-
-
Save whatalnk/f7c43ad96dd02afec13da996c160cf68 to your computer and use it in GitHub Desktop.
AtCoder ARC #040 B - 直線塗り
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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