Parallel Processing | Can anyone tell me why only my 3rd task is not passed

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.

Thank you!

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. :grin:

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 break.

can you help me in this question link is Contest Page | CodeChef
my submission link is Solution: 59333177 | CodeChef
in my solution for ans=1,2 i take last pole which is different and check before this and after this is both side are not sorted then ans is 2 else ans is 1.