Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # *-* coding: utf-8 *-*
- from __future__ import division
- import sys
- DEBUG = False
- def where_should_i_ve_been(z):
- return ['B' if not i[1] or (i[0] and 700*(i[1]+1) < 300*(i[0])) else 'A' for i in z]
- def money_awarded(z, y):
- retval = 0
- for i in xrange(len(z)):
- retval += 700/(z[i][0]+1) if y[i] == 'A' else 300/(z[i][1]+1)
- return retval
- # x represents the history of populations
- x = []
- # y represents my choices
- y = []
- # z represents the history - my choices
- z = []
- for i in xrange(10):
- sys.stdout.write('A\n')
- sys.stdout.flush()
- line = sys.stdin.readline()
- x.append(map(int, line.strip().split(' ')))
- y.append('A')
- z.append([x[i][0]-1, x[i][1]])
- for i in xrange(70):
- evaluations = []
- for ps in xrange(1, int(len(x)/2)):
- inter = where_should_i_ve_been(z[-2*ps:-ps])
- evaluations += [(money_awarded(z[-2*ps:], inter*2)/ps, inter)]
- if DEBUG:
- print ps, z[-2*ps:-ps], inter, evaluations[-1]
- best = max(evaluations)
- sys.stdout.write(best[1][0]+'\n')
- sys.stdout.flush()
- line = sys.stdin.readline()
- x.append(map(int, line.strip().split(' ')))
- y.append(best[1][0])
- z.append([x[i][0]-(1 if best[1][0] == 'A' else 0), x[i][1]-(1 if best[1][0] == 'B' else 0)])
- if DEBUG:
- print y
- print "Mi elección:", money_awarded(z, y)
- print "A constante:", money_awarded(z, ['A' for a in xrange(len(z))])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement