ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2015. Zhenya moves from the dormitory

WA5 . Where is mistake?
Posted by Lev_Kireenko 🐬 29 Jul 2016 00:04
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
Re: WA5 . Where is mistake?
Posted by exwRabbits_AlMag(VNTU) 13 Dec 2022 02:57
fun2 is when you live alone, so you can't add fun2 when living with a friend