Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- # Auto-generated code below aims at helping you parse
- # the standard input according to the problem statement.
- robbers = int(raw_input())
- vaults = int(raw_input())
- print >> sys.stderr, robbers, vaults
- numbers = 10
- vowels = 5
- characters = [0] * vaults
- digits = [0] * vaults
- def process_window(window_length, seconds):
- lowest_seconds = 999999999999999999999999999999999999999999999999999999999
- for i in xrange(window_length):
- if seconds[i] < lowest_seconds:
- lowest_seconds = seconds[i]
- return lowest_seconds
- def find_blanks(window_length, seconds):
- index = []
- for i in xrange(window_length):
- if seconds[i] == 0:
- index.append(i)
- return index
- for i in xrange(vaults):
- characters[i], digits[i] = [int(j) for j in raw_input().split()]
- print >> sys.stderr, characters[i], digits[i]
- # Write an action using print
- # To debug: print >> sys.stderr, "Debug messages..."
- seconds = []
- # compute seconds for each vault
- for i in xrange(vaults):
- first_combo = pow(numbers, digits[i])
- num_charcters = characters[i] - digits[i]
- second_combo = pow(vowels, num_charcters)
- seconds.append(first_combo * second_combo)
- total_seconds = 0
- print >> sys.stderr, seconds
- while seconds:
- time_taken = 0
- window_length = 0
- # find windows length
- if robbers < len(seconds):
- window_length = robbers
- else:
- window_length = len(seconds)
- # find time in window
- time_taken = process_window(window_length, seconds)
- total_seconds += time_taken
- ## take time and remove 0 time elements
- for i in xrange(window_length):
- seconds[i] = seconds[i] - time_taken
- items_to_remove = find_blanks(window_length, seconds)
- for item in items_to_remove:
- seconds.pop(item)
- print >> sys.stderr, time_taken, seconds, total_seconds
- print total_seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement