Need Help in checking Testcases for "Buying candies "

I was solving this problem from NEWB2020. And I wrote 2 solutions for this problem.
SOLUTION1
SOLUTION2
After putting an assertion a[i]!=0 I got sigbart error, is this enough to prove that there is some issue with the test cases or there is some error at my side?
@arghya_n
@aref111n

2 Likes

https://www.codechef.com/viewsolution/38908700
This is my solution that got wrong answer and it is the same as your implementation. Turns out that you just need to traverse the array from backwards and the code would get accepted. I still do not understand how will that change the answer. It would be great if someone could provide a test case for the same.

Bro test cases are wrong as assertion failed, a[i] can’t be zero according to constraints. They are not even addressing this in the comments section .

1 Like

I wasted so much of time on this question, could’ve got much better rank

1 Like

Just a guess from what I’ve seen so far.

Vector gives WA.

Array gives AC.

Why!??

1 Like

That’s weird, but what about the failed assertion but ?

I faced the same issue :frowning:

That’s the weirdest shit i’ve heard in a while , considering i even gave yesterday’s controversial CF EDU round lo;

Seriously, where are the authors man, why aren’t they addressing this ?

My Python code gave Run time error but the same logic in C++ gave AC.

@cubefreak777
You your data types were integer…It can not perform all the cases bacause Pi and K was in limit of 10^9
…

1 Like

I tried with long long 's too , check this. Also, the assertion is not affected by the data type, it should have given a WA instead

1 Like

Why is mrTL9N - Online C++ Compiler & Debugging Tool - Ideone.com wrong?

@cubefreak777

if(m/a[i] >= k){
ans= a[i] ;
break ;
}

My question ,Can this division gets correct ans ?With just integer division …

1 Like

Just answer this, why is the assertion failing ?. And answer to your question, I think it will give the right answer.

Can you please confirm if you had any testcase with p[i] =0 ?

p[i] should be obviously > 0.If there is any fault with my test .Then I am very sorry I will try to rejudge the solutions.

If there is any test like this then I will say sorry and obviously I will try to rejudge it…

Thanks a lot, I’m just requesting you to look if that was the case or not cause that’s what I was able to infer from the results, I might be wrong.

Yup. My code in my contest just got an AC. Thanks. Anyway, will the standings be updated?