WA5 . Where is mistake?
cost, fun1, fun2 = map(int,input().split())
fri, flat2 = [], []
for i in range(int(input())):
fri.append(list(map(int,input().split())))
temp1, temp2 = [-1,-1], [-1, -1, -1] #веселье, квартрира, сосед
for i in range(int(input())) :
a, b, c = map(int,input().split())
if a == 2 :
flat2.append([b,c,i+1]) # стоимость, веселье, номер
if fun1 + c > temp1[0] and cost >= b :
temp1 = [fun1+c, i+1]
for i in range(len(flat2)) :
b, c, k = flat2[i][0], flat2[i][1], flat2[i][2]
for j in range(len(fri)) :
if fri[j][0] >= b/2 and cost >= b/2 and fun2+fri[j][1]+c > temp2[0] :
temp2 = [fun2+fri[j][1]+c, j+1, k]
if temp1[0] == -1 and temp2[0] == -1 :
print('Forget about apartments. Live in the dormitory.')
elif temp1[0] > temp2[0] :
print('You should rent the apartment #'+str(temp1[1])+ ' alone.')
else :
print('You should rent the apartment #'+str(temp2[2])+' with the friend #'+str(temp2[1])+'.')
Edited by author 16.09.2016 21:53