Problem Link:- Paraller Processor
Use long long int.
Your code is failing for cases when the input is large. It can’t be stored in the int data type, hence use long long int.
can anyone tell me why my submission is wrong
You are initializing d with
INT_MAX, whereas you should initialize it with
LLONG_MAX or the sum.
Because d can go beyond the range of int
thank you so much.
Could you please help me out too? I have been stuck for a long time. The output is correct and i have used long long int too, Yet i get RE and TLE.
I didn’t go deeper into the way your code works, but I saw that you are using a
break statement for the case when input n is 1. Always remember that never use a break when you are just inside the t (test case) while loop. This is because it will terminate your program and will stop taking any more test cases. I am guessing that might be leading to these errors.
Alternatively, you could use
continue in place of