We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I am using C++ language. Some of the test cases have some very large numbers. To calculate average waiting time, either we can first calculate total time and then divide it by n or we can divide by n while adding any number to the total time. In the first approach, the total time becomes very large and goes out of range of even long and in second approach, there is some round-off error which gets added each time and final answer might be little smaller than the correct answer. I am stuck at this. Can anybody please help? Thanks in advance!
Minimum Average Waiting Time
You are viewing a single comment's thread. Return to all comments →
I am using C++ language. Some of the test cases have some very large numbers. To calculate average waiting time, either we can first calculate total time and then divide it by n or we can divide by n while adding any number to the total time. In the first approach, the total time becomes very large and goes out of range of even long and in second approach, there is some round-off error which gets added each time and final answer might be little smaller than the correct answer. I am stuck at this. Can anybody please help? Thanks in advance!