Algorithmic Burglar

Several vaults were broken into last night! Police have strong evidence to believe that the culprit was the infamous Algorithmic Burglar - an efficient and swift robber.

7 different vaults were robbed. Police discovered that the vaults are missing the following amounts of metal: 1739 lbs, 72 lbs, 212 lbs, 55 lbs, 511 lbs, 1239 lbs, and 99 lbs.

Here are the weights and dollar values for the different bars in the vaults:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Material    Weight  Value
Gold        2 lbs   $57
Platinum    5 lbs   $191
Silver      14 lbs  $417
Expensivium 17 lbs  $231
Rhodium     19 lbs  $741
Osmium      13 lbs  $139
Aluminum    1 lbs   $28
Silicon     3 lbs   $117
Iron        5 lbs   $13
Titanium    11 lbs  $9
Potassium   19 lbs  $18

Before the robbery, each vault contained at least 2000 lbs of each metal. Assume the burglar stole whole bars, not fractions of a bar.

Let V be the greatest possible value in dollars of the stolen material. What are the last three digits of V ?


The answer is 153.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Yitz Deng
Jun 27, 2014

Mathematical solution:

Rhodium and Silicon have the highest value per pound at $39. Since all the missing weights are above 38 pounds, any combination of Rhodium and Silicon bars will get us to a wanted missing amount of metal, because 19 is 1 mod 3, so if the missing amount is 1 more than a multiple of three, we just have one multiple of 19, and if the missing amount is 2 more than a multiple of 3, then we have two multiples of 19. The rest of the missing metal can be stolen through silicon bars.

Thus the maximum value of missing metal is just the sum of all of the missing metals multiplied by $39, and that's 153153 so the answer is 153 \boxed{153} .

Thaddeus Abiy
May 11, 2014

It should be obvious that the maximum amount of obtainable money from N N pounds is the maximum possible value of obtainable money from N i N-i pounds(where i i is the cost of any one of the listed bars in the weight-dollar values) plus the cost of the bar itself.This is a recursive relation which can be optimized using Dynamic Programming.

Python code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#Dynamic programming once again!
Bars = [(2,57),(5,191),(14,417),(17,231),(19,741),(13,139),(1,28),(3,117),(5,13),(11,9),(19,18)]
Max = {0:0} 
Pounds = 0
while Pounds <= 2000:
    Pounds += 1
    Largest = 0
    for bar in Bars:
        Remaining = Pounds - bar[0]
        if Remaining < 0:
            continue
        else:
            Value = Max[Remaining] + bar[1]
            if Value > Largest:
                Largest = Value
    Max[Pounds] = Largest
V = Max[55]+Max[72]+Max[99]+Max[212]+Max[511]+Max[1239]+Max[1739]
print V % 1000

I came up with the solution 153145(using O-1 Knapsack) and I think it is the greatest possible value.The last three digits of V are hence 145 and not 153.

Swapnil Bhargava - 6 years, 12 months ago

We can discard Iron and Potassium, as they have the same weight as others with better value.

Laurent Shorts - 5 years, 1 month ago
Vishal Mittal
Jul 30, 2019

This is classical fractional knapsack problem.

Below is the C++ code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;

int wt[] = {2, 5, 14, 17, 19, 13, 1, 3, 5, 11, 19};
int price[] = {57, 191, 417, 231, 741, 139, 28, 117, 13, 9, 18};
int N = 11;

int knapsackDP(int W)
{
    int dp[2][W+1] = {0};
    for(int n = 0; n <= N; n++)
    {
        for(int w = 0; w <= W; w++)
        {
             if(n == 0 || w == 0)
                 dp[1][w] = 0;
             else
             {
                  int inc = 0, exc = 0;
                  if(wt[n-1] <= w)
                        inc = price[n-1] + dp[1][w - wt[n-1]];
                  exc = dp[0][w];
                  dp[1][w] = max(inc, exc);
              }
          }
          for(int i = 0; i <= W; i++)
               dp[0][i] = dp[1][i];
      }
      return dp[1][W];
}

int main() 
{
    int ans = 0;

    ans += knapsackDP(1739);
    ans += knapsackDP(72);
    ans += knapsackDP(212);
    ans += knapsackDP(55);
    ans += knapsackDP(511);
    ans += knapsackDP(1239);
    ans += knapsackDP(99);

    cout << ans << endl;
    return 0;
} 

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...