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 fun2 is when you live alone, so you can't add fun2 when living with a friend Try to reread the task. I've been adding up wrong numbers together because of the misunderstanding. Also, try tests from "If you have WA6" Edited by author 25.10.2017 07:16 98000 3334 3334 1 25000 3333 3 1 97999 1 2 30000 1 2 25000 1 Answer - You should rent the apartment #1 alone. or You should rent the apartment #2 alone. or You should rent the apartment #3 alone. 21111 1111 7777 5 1111 7777 10000 6556 20000 3131 80000 2 76400 1 4 1 21110 6000 1 21111 6665 2 21111 1220 2 1110 0 Answer - You should rent the apartment #3 alone. 1001 1001 1001 1 1001 1 1 2 1001 1 Answer - You should rent the apartment #1 alone. I hope it can help. My program, which got WA 6, failed on this tests. Please, give me some tests. I can't understand why i get WA4. Please make sure your solution meet the requirement "If two people share an apartment, each pays half of the rent." This is that I missed in my first solution. I did this, but it's still WA4. Chto za xren Test 5? Does anybody know what the hell is Test 5? Check if you comparing right prices for 2-rooms apartment when person lives single. Try this test: 1 0 0 0 1 1 1 0 Answer: You should rent the apartment #1 alone. Please give me some tests this is my code: #include <iostream> using namespace std; int main() { long sj,prj1,prj2,n,k,sd[256],prd[256],kom[256],sh[256],prh[256]; cin>>sj>>prj1>>prj2>>n; for(int i=0;i<n;i++) cin>>sd[i]>>prd[i]; cin>>k; for(int i=0;i<k;i++) cin>>kom[i]>>sh[i]>>prh[i];
long max=-1,nh=0,nd=0;
for(int i=0;i<k;i++) if(kom[i]==1) { if(sh[i]<=sj&&(prj1+prh[i]>max)) {max=prj1+prh[i];nh=i+1;nd=0;}} else { if(sh[i]<=sj&&(prj2+prh[i]>max)) {max=prj2+prh[i];nh=i+1;nd=0;} for(int j=0;j<n;j++) if(sh[i]<=int(double(sj)/2.0+double(sd[j])/2.0)&&(prh[i]+prd[j]>max)) {max=prh[i]+prd[j];nh=i+1;nd=j+1;} }
if(nd==0) {if(nh==0) cout<<"Forget about apartments. Live in the dormitory."<<endl; else cout<<"You should rent the apartment #"<<nh<<" alone."<<endl; } else cout<<"You should rent the apartment #"<<nh<<" with the friend #"<<nd<<"."<<endl;
return 0; } Edited by author 29.11.2014 15:08 Если двухкомнатная квартира стоит нечётную стоимость, как делится её цена? As like as for even cost. Если была стоимость 5, то каждый платит по 2,5. Если бы делилось как четное, то будет WA18 - проверено. Так что считайте, что могут не целые числа. Edited by author 28.11.2014 01:41 Edited by author 28.11.2014 01:41 Give me some tests please Not related to WA5, but to WA4 - perhaps it helps anyway: I got wa4 when forgot to add the advantage of each apartment, to the total value, before comparing to current max. I got WA5. But I have passed it. My error was in copypast. When I was comparing current maximum, I used wrong massive. I want to calculate maximum living along in 2 bedroom apartment massive , but I took values from one bedroom apartment massive :( |
|