Postman
Time limit8sMemory limit256 MB
- Level
Not classified yet
- Solved
- No attempts yet
Statement
Johnny has just become a postman. He is new to the company, so he got the worst assignment: delivering urgent mail to a new neighborhood. The delivery deadline is exactly one hour away. The postal company has also introduced a new customer-friendly rule: for each letter delivered after its deadline, the company pays compensation of bythaler for every hour of delay.
The neighborhood has houses, numbered from to . Johnny has to deliver one letter to each house. The houses are connected by two-way streets, so any house can be reached from any other house by following the streets.
Johnny must deliver the letters as soon as possible. Due to company driving regulations, a company car takes him to one house of his choosing, and after that Johnny walks. The ride takes exactly one hour, so he delivers exactly one letter on time. Walking along a street takes exactly one hour. Dropping a letter in a mailbox takes no time. Johnny has to deliver all the letters.
Johnny knows that on-time delivery is impossible, but he still wants to minimize the total compensation the postal company pays. Write a program that reads the number of houses and the streets, computes the minimum compensation for late deliveries, and prints it.
Input
The first line contains a single integer (), the number of houses. Each of the next lines contains two integers and (), separated by a space, meaning houses and are directly connected by a street.
Output
Print the minimum compensation in bythalers.
Hint
Johnny can be dropped off at house 1 and deliver the letter on time, so the compensation is . Then he walks to house 2 and delivers the letter with compensation of , then walks to house 3 and delivers with compensation of . Next, he returns to house 2, walks on to house 4 and delivers there with compensation of , returns to house 2 again, walks to house 5 and delivers the final letter with compensation of .