注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 kevinanderson 于 2019-11-11 17:16 编辑
/*
* [1.2, .9, .2] => [1, 1, 0]
* 1. rounded(sum(input) = sum(output)
* sum(input) = 2.3, rounded(sum(input)) = 2
* sum(output) = 2
* 2. Minimizing the sum of differences between each individual price
* differences = [.2, .1, .2], sum of diffs = .5
*
* [.3, .3, .3] => [1, 0, 0]
0,0,1 .1
* [1.4, .9, .4] => [2, 1, 0] =>
* sum(input) = 2.7, rounded(sum(input) = 3
* sum(output) = 3
*/
Private List<Integer>f;
Int index;
Node(double diff, int index) {
This.diff = diff;
This.index = index;
}
@Override
Public int compareTo(Node that) {
If(this.diff < that.diff) {
Return 1;
}
Return -1;
}
}
|