-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
public class BestLoading {
public float loading(float maxWeight, float[] weights, List x) {
int n = weights.length;
Element[] d = new Element[n];
for (int i = 0; i < n; i++) {
d[i] = new Element(weights[i], i);
}
java.util.Arrays.sort(d);
float op = 0;
for (int i = d.length -1; i > 0; i--) {
if (d[i].weight > maxWeight)
continue;
if (op + d[i].weight >= maxWeight)
break;
op += d[i].weight;
x.add(d[i].index);
}
return op;
}
}
Metadata
Metadata
Assignees
Labels
No labels