← 返回 apple 的题目列表Maximize Ore Collection with Limited Time
类型:online_judge
Given a graph where each node represents a mine and contains some ores, and numbers on edges represent travel time between mines. Starting from mine #0, you must collect ores and return to mine #0 within a limited time, counting the return travel time. You may visit mines multiple times but cannot collect the same ore twice. Given a max time, return the maximum ores collected within the max time.
Example
Value of ores: [0, 32, 10, 43] // ore counts in each mine, mine #1 has 32 ores
Edges: [[0, 1, 10], [1, 2, 15], [0, 3, 10]] // it takes 10 seconds/mins/hours to travel from mine #0 to mine #1
Max time: 49
Should return: 75
Steps
First, travel from 0 to 3: collecting 43 ores, traveling takes 10, time left: 39
Returning to 0 takes 10, time left: 29
From 0 to 1, collecting 32 ores, traveling takes 10, time left 19
Returning to 0 takes 10, time left: 9, not enough time to travel anywhere else.
Example
Input
{"value": [0, 32, 10, 43], "edges": [[0, 1, 10], [1, 2, 15], [0, 3, 10]], "max_time": 49}