Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 802 | Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) | FINISHED | False | 16200 | 280446923 | May 28, 2017, 8:05 a.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 733 ) | J2 | Send the Fool Further! (medium) | PROGRAMMING | dp trees | 2100 |
Thank you for helping Heidi! It is now the second of April, but she has been summoned by Jenny again. The pranks do not seem to end... In the meantime, Heidi has decided that she does not trust her friends anymore. Not too much, anyway. Her relative lack of trust is manifested as follows: whereas previously she would not be made to visit the same person twice, now she can only be sure that she will not be made to visit the same person more than k times. (In the case of Jenny, this includes her first visit in the beginning. The situation from the easy version corresponds to setting k = 1 .) This is not as bad as it looks, since a single ticket for a route between two friends allows Heidi to travel between this pair of friends the whole day (in both directions). In other words, once she pays for travel between a pair of friends, all further travels between that pair are free. How much money will Heidi waste now, in a worst-case scenario? The first line contains two space-separated integers – the number of friends n ( ) and the parameter k ( 1 ≤ k ≤ 10 5 ). The next n - 1 lines each contain three space-separated integers u , v and c ( 0 ≤ u , v ≤ n - 1 , 1 ≤ c ≤ 10 4 ) meaning that u and v are friends and the cost for traveling between u and v is c . It is again guaranteed that the social network of the input forms a tree. Again, output a single integer – the maximum sum of costs of tickets. In the first example, the worst-case scenario for Heidi is to visit the friends in the following order: 0, 1, 5, 1, 3, 1, 0, 2, 6, 2, 7, 2, 8 . Observe that no friend is visited more than 3 times. |
| helvetic-coding-contest-2017-editorial.pdf |
No solutions yet.