22bce7873 Asg6
22bce7873 Asg6
import java.util.*;
class Item {
double ratio;
this.profit = profit;
this.weight = weight;
if (items[i].weight > m) {
break;
} else {
x[i] = 1;
profit += items[i].profit;
m -= items[i].weight;
}
}
int n = scanner.nextInt();
int m = scanner.nextInt();
w[i] = scanner.nextInt();
knapsack(n, m, p, w);
scanner.close();
OUTPUT:
-------------------------------------------------END------------------------------------------------------