Created by @Nagrarok,validated by @bbb000bbbyyy,@JBM and @Razovsky.
If you have any issues, feel free to ping them.

Very nice puzzle.
It took me a bit to figure out the elegant solution as I started with a direction that proved way too complicated for the problem at hand.

Kudos to the creator of the puzzle. Nicely done !

I donâ€™t know why i have problem with 2 last test cases especially â€śMany real friendsâ€ť case where only positive joy. my result is 25259954

All test cases pass, but validation fails at no. 6. Any idea?

I do not understand the first test case :

4 10 5
9 4
7 10
9 3
6 1

output : 7

If I bring 2 friends, travel cost would be of (2 * 5 + 10) / 3 = 6.66â€¦ , so I can bring the one that brings me 10 joy and the ones with 4 joy and I would get with 2 friends 14 joy ?
Where am I wrong ?

Youâ€™re wrong because â€śthey wonâ€™t accept money from othersâ€ť.

Each friend has to pay its additional cost and then the base cost is divided between each in equal parts.

So for you and too travelers, they have to pay 5+3.33 â€¦only those with 9\$ can pay and you get 7.

1 Like

I think you missed the following sentence
â€śYour friends have their pride: they wonâ€™t accept money from others, hence every traveler - including yourself - has to pay the same priceâ€ť

So each of your friends have to pay 5+10/nbTravellers
If you bring 2 friends you will be 3 travellers (2friends+you), so everybody will need to pay 5+10/3=8.333
If you bring 3 friends, the cost per friend will be 5+10/4=7.5
If you bring 4 friends, the cost per friend will be 5+10/5=7

Considering the different budgets of the friends, you can only bring the 2 friends with a budget of 9. Thus the 7 joy

2 Likes

got it than you

Itâ€™s my solution, passes all test cases but fails on validations at â€śOnly base costâ€ť.

I have the same problem, I tried also to take the date and do it in exel. I gave 25259954 as result.

I have the same problem

@DarvasKristof & @Amire1 â€śOnly base costâ€ť are the `P = 0` tests and validators.

I understand it. But what could be that reason why test works and validator doesnâ€™t?

@DarvasKristof Well, the reason simply could be that youâ€™ve been lucky on the test. Consider the two following inputs to help debugging (and once itâ€™s done, please erase your code from here ^^).

``````5 87 0
15 -13
16 7
77 17
38 -15
26 16
==================
``````
``````5 95 0
29 5
29 -13
5 -16
20 -3
31 17
=================
``````
2 Likes

Thank you, itâ€™s erased

Thanks, I found the solution!!
(Donâ€™t you want to add an extra testcase for my mistake?)

1 Like

This puzzle is not defined unambiguously. Took me a while to figure out how the ambiguity situations are taken/ment from authorâ€™s point of view.

If you like me that we understand wrong of requirement of this puzzle. Iâ€™m taking all friend into invite list and consider they are going event if they donâ€™t have enough money so the cost for each person is wrong. Addition is couting yourself as 1.

• Like first test case you count costEachperson = 10/4+ 5= 7.5 --> wrong
is will be 10/3 +4 = 8.3
• itâ€™s 2 friend with budget 9 and including you.

I cosidered all of those things. But still, does not work.

Hm after Dr.D someone in this community tell me that i already solved it. may be you should recheck your solution about it.