Dec 24, 2018 at 10:41am UTC
> freq[0]=1;
¿why are you doing that?
the problem specifically says that there are no empty boxes
also, if you have TLE, you may replace lines 27--32 with (freq[i]*(freq[i]+1)) / 2
Dec 24, 2018 at 2:46pm UTC
@ne555
I am not getting tle. Execution time is in milliseconds.
I am doing freq[0]=1 for k balls as freq[0] will be 1.
So,
k x 1=k.
otherwise will get 0
I think you mean (freq[i]*(freq[i]- 1)) / 2
I am getting wrong answer. But it is right for test cases
Last edited on Dec 24, 2018 at 2:51pm UTC
Dec 24, 2018 at 3:56pm UTC
Are lines 27-32 correct? If i==k/2 then you choose 2 boxes from freq[i]. So if X=freq[i] then it's X! / (2! * (X-2)!) == X*(X-1)/2 ... I think....
Dec 24, 2018 at 5:16pm UTC
@dhayden
suppose I have 3 3 3 3 and k is 6
then
no of combinations is 3+2+1=6 where freq[3]=4 and start=4-1=3
Last edited on Dec 24, 2018 at 5:17pm UTC
Dec 24, 2018 at 5:28pm UTC
> I am doing freq[0]=1 for k balls as freq[0] will be 1.
> So,
> k x 1=k.
> otherwise will get 0
¿is that correct? ¿do you may select just one box or do you need to always get two?
perhaps 0 is the correct answer
> I think you mean (freq[i]*(freq[i]-1)) / 2
yes, my bad
Dec 25, 2018 at 3:43am UTC
@ne555
Oh yes, this was the issue. selection of one box was not allowed.
thankyou:)