thank you so much @anon52057084
hey even i got 6,7,9 wrong test cases, but for your test case i get answer as 4 can u check my solution here
Thank you for helping me out.
This worked for me as well. But what were the test cases that we missed? OR Why did we add this 2*, i didn’t get it yet. Can you please tell the logic behind this **2 ** * p[i] >= x ?
Can someone tell me the answer of this test case?
1
2 4
7 14
The problem is accepting 3 as the answer whereas the answer should be 4.
- If you give 4 cures in day 1, next day you can give only 6 cures because population becomes (7-4)*2=6. so in day 2 you can give 6 cures. On day 3, you can give 12 cures which is less than 14 so total 4 days is required. In no ways you can give all 7 cures in second day.
Try:
1
2 10
9 18
Ans: 2
On the day 2 you can send delivery man to 2nd country and can give 8 cures.
It means for second country you require 2 days because population is 14 so the answer is still 4
[CodeChef: Practical coding for everyone]
Can someone find error in my code. 2 test cases failing.Can somebody give me a failed test case…
A very simple solution:
https://www.codechef.com/viewsolution/35417013
see line number 22 to 47
Only 2 if conditions inside the for loop used to iterate sorted array.
WHY ll= x/2+x%2 ; why not ll=x ??
sorry i was wrong …my bad
on first day we send our delivery man to second country now we have 8 vaccine, ( 7 infected in country 1st and 14 infected in country 2nd) ,then on second day we send him to 1st country now we have 14 vaccine ( 0 infected in 1st country and 14 in 2nd country) , on third day we send him to cure 2nd country. I hope it’s clear now.
In subtask 2, it think it should be 2 * Ai >= x .
I presume you are asking if we can deliver to that country if 2*a_i=x. Yes, we can. We can deliver to that country while doubling x or at the end. Either way it accounts for only 1 day for that country. My algorithm choses to deliver at the end.
I get you. Even I was thinking the same, I know many have done just hit and trail. I tried to get a proof and I submitted it assuming maximum population will always have enough people to be cured so that we can every time double supply for some country having less population.
@sudipandatta can you provide me some valid argument to prove ? it’d be helpful
Help!
Please correct if I am wrong.
As per question only way of doubling the x is to deliver the cure to a country that has infected_population > =x and that countries infected_population decrease by x and become double (or initial population). But when we will cure the last country it is possible our x can drop down at last day.
Example test case:
n=3 x=30
14 55 111
day 1> x=30 ar=[14, 55, 111] deliver x to 110 and it will become 110 next day again
day 2> x=60 ar=[14, X, 111] deliver x to 55
day 3> x=110 ar=[14, X, 1] deliver x to 111
day 4> x=220 ar=[14 ,X,2] deliver x to 2
day 5> x=4 ar=[14, X, X] deliver to 14
day 6> x=8 ar=[6, X, X]
day 7> x=16 ar[X,X,X]
But the correct ans is 5 days
can anyone help me under the algorithm because I think I am missing something.
I think as if the author has just taken x=ar[n-1]*2 at last without taking the reducing population of ar[n-1] in consideration.
Try this TC:
1
3 7
3 14 28
ans is 4 days
your solution will give 5 days
reason: you are checking for (x/2) which gives 3 and you are starting from 1st country instead of 2nd country you should do (x+1)/2
in case of odd x and x/2 in case of even x.
thanks a lot man!!