#FW0000096. Chuyến đi mua sắm tiết kiệm (Shopping Trip)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chuyến đi mua sắm tiết kiệm (Shopping Trip)
Shopping Trip
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Daniel lives at node and there are stores . Each bidirectional road has a travel cost in dollars. Each DVD offer at store yields a saving relative to ordering online. Daniel may skip offers, but any shopping route starts and ends at home. Maximize total shopping savings minus fuel costs, in exact cents. Multiple offers at one store can be collected on a single visit.
Input
First , then roads with costs having two decimal places. Next and lines giving available savings.
Output
Print Don't leave the house if no positive net saving is possible; otherwise Daniel can save $X.YY.
Subtasks
-
Subtask 1 (40 points): . All input-format and graph conditions above apply.
-
Subtask 2 (60 points): . All input-format and graph conditions above apply.
Examples
Input
1 1
0 1 1.00
1
1 5.00
Output
Daniel can save $3.00
Explanation
Travel from home 0 to store 1 and back costs . The item saves , leaving a net benefit of .