why I am getting wrong answer after submitting my code which corner case is missing .
All the sample outputs matched.
This was mentioned in the problem.
Also after the operation, none of the seller’s bucket should be empty.
So, the following statement
int op1=grape%k;
should be modified to
int op1 = (grape <= k ? (k - grape) : (grape % k));
Also, after making the above change, you’re likely to get WA and TLE.
- Wrong Answer because the constraints are very high and long long int should be used
- TLE because of the following snippets.
int another(int grape,int k) // functions for another way of operation count
{
int count=0;
while(grape%k!=0)
{
grape++;
count++;
}
return count;
}
int op2=another(grape,k);
The whole function, ‘another’, can be replaced with the following function.
int another(int grape, int k) {
return (k - grape % k;)
}
Try doing the above modifications, I believe this will work.