示例#1
0
 public void Knapsack()
 {
     Assert.Equal(3, Greedy.Knapsack(1, new int[, ] {
         { 6, 2 }
     }));
     Assert.Equal(6, Greedy.Knapsack(2, new int[, ] {
         { 6, 2 }
     }));
     Assert.Equal(3, Greedy.Knapsack(1, new int[, ] {
         { 10, 5 }, { 3, 1 }
     }));
     Assert.Equal(43, Greedy.Knapsack(10, new int[, ] {
         { 10, 2 }, { 5, 3 }, { 15, 5 }, { 7, 7 }, { 6, 1 }, { 18, 4 }, { 3, 1 }
     }));
 }