Created
May 9, 2011 02:46
-
-
Save rmmh/961961 to your computer and use it in GitHub Desktop.
Google Code Jam 2011 Prelim Round A
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_cases = input() | |
for case in xrange(1, n_cases + 1): | |
bot = {'O': [1, 0], 'B': [1, 0]} | |
buttons = raw_input().split()[1:] | |
buttons = zip(buttons[::2], map(int, buttons[1::2])) | |
time = 0 | |
for color, pos in buttons: | |
last_pos, last_time = bot[color] | |
time += 1 + max(0, abs(pos - last_pos) - (time - last_time)) | |
bot[color] = [pos, time] | |
print "Case #%d: %d" % (case, time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment