You are attempting a legendary pub crawl across town.
The town has $$$k$$$ junctions which are connected by $$$m$$$ roads. There is a pub at each junction. Each road could be traveled in both directions and has a non-negative travel time. There could be multiple roads between the same pair of junctions. You start the pub crawl at time $$$0$$$ in pub $$$1$$$.
Pub $$$i$$$ is located at junction $$$i$$$ and will close at absolute time $$$c_i$$$. A pint must be finished at or before closing time in order to count.
Your drinking ability changes as the night goes on: The 1st pint takes $$$t_1$$$ time units, The 2nd takes $$$t_2$$$, and so on, with the $$$r$$$-th pint taking $$$t_r$$$. Please note that $$$t_i$$$ are not necessarily increasing.
You may visit pubs in any order (not necessarily starting by drinking at pub $$$1$$$) and may return to the same pub multiple times, but you cannot drink two consecutive pints in the same pub.
Your task is to maximize the number of pints consumed before closing times run out.
Output an integer — the maximum number of pints you can drink before all of the pubs are closed.
860 120 180 240 300 360 420 4802900 150012 1 90
4
102 2 2 2 2 3 3 3 3 3435 30 15 3041 2 53 4 14 1 53 2 1
7
| Name |
|---|


