ENG  RUS Timus Online Judge Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1876. Centipede's Morning

Understanding the solution
Posted by MARAZ MIA 22 Feb 2020 03:06
After so many calculation and math I have solved the problem.....
Here we can have two worst cases...

Case 1:
having all the right shoes first.so here needed time is 2*b and we have now all the left shoes remaining...so total time is 2*b+40...

Case 2:
we may have 39 right shoes so time needed here is (39*2=78)...then we have only one right foot left but we may encounter all the left shoes and here needed time is 40+2*(a-40)....> 40 for the first 40 shoes and 2*(a-40) is for the remaining shoes as they needed to be thrown away...then we have the only one right foot left and it need 1 second...
so total time = 78+40+2*(a-40)+1 = 119+2*a-80 = 2*a-39

ans=max(Case 1,Case 2)

Edited by author 22.02.2020 03:07