RUNDIR double vs long double

Problem:
N students are standing at distinct points in the X-axis. Every students will start running at t = 0. assign direction (left/right) to each of them such that the first time when any two students cross each other is as large as possible. Speed of every students is given.

i spent / wasted several hours on this question. the following are two of my many submissions :

  1. https://www.codechef.com/viewsolution/18630732

  2. https://www.codechef.com/viewsolution/18628847

the only difference between the 2 codes is that at line no.72 i used “double” in ‘1’ and “long double” in ‘2’.

there is absolutely no other difference between either submissions.

the first submission gives me AC where as the second gives me WA.

what could be the reason for this?

long double is as precise as double is if not better. then why the WA?

real culprit was printf…
I think you missed something in format specifier…

include<iomanip>
and try
cout << setprecision(10) << mid;

the actual problem was that i used “printf(”%0.10lf\n", mid)" instead of “printf(”%0.10Lf\n", mid)" (CAPITAL ‘L’).
so for double its “%lf” and for long double its “%Lf”.
thanks.

which would give you AC… i suggest never use printf scanf… use cin cout
and for fast I/O try

 #define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)   

 int main(){
     FIO;  
     //body...
     return 0;
 }

moreover keep stuck to a single data type…
either int or strictly long long int
either float or strictly double or strictly long double…

keeping one data type int and another long long int needs too much care for typecasting so its like “use this at your own risk !!”
and same for float or double or long double
I had wasted my very much time for this issue… now I just use…

  #define ll long long int    

Now each time I need long long int I just do CTRL+H(find and replace)
and replace int by ll
and then edit
ll main to int main
and
#define ll long long ll to #define ll long long int
hope this helps :smiley:

PS: I saw you had used double as well as long double in the solution…

yeah welcome…