SAVEENV - Save the Environment
Your company pays you $0.55 per mile that you drive your own car while you’re delivering pizzas, which is definitely more than you pay for gas. But they’ve installed a GPS system that tracks where you drive, and won’t credit you if you retrace your own steps.
You need to get from point A to point B via the longest possible path, so as to maximize your earnings. Given a set of waypoints, with the distances between them, return the total reimbursement you’ll be requesting if you travel from A to B via the longest path.
You can drive either way between waypoints, and can visit the same waypoint multiple times (including A or B), but you can’t travel along the same path between the same two waypoints twice. There may be multiple paths between the same two waypoints.
Input:
Distances between waypoints, separated by spaces. For example, “A5C C12B” means that the distance from A to C is 5 miles, and from C to B is 12 miles. The distance will always be a positive integer. Waypoint labels are always one letter.
Output:
The dollar amount you’ll be reimbursed if you drive the longest path from waypoint A to waypoint B, formatted to 2 decimal places.
Input | Output |
A5C C12B | 9.35 |
A3C C9D A4D A2B B7D | 10.45 |
A1C C1D D1A A1B B1E E1F F1B | 3.85 |
A1B A1B A1B | 1.65 |
hide comments
Erik Lonèarek:
2012-10-23 15:40:08
- No constrains
|
Added by: | Ben Dilts |
Date: | 2012-10-12 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |