function getMoney(total, maxSeal, loseArr, sealCount) {
var result = 0;
var tempArr = loseArr.sort();
tempArr = loseArr.splice(0, sealCount);
if(sealCount <= maxSeal) {
for(var i = 0; i < sealCount; i ++) {
result += tempArr[i];
}
return result;
} else {
var k = Math.ceil(sealCount / maxSeal);
tempArr = tempArr.reverse();
for(var i = 1; i <= k; i ++) {
for(var j =0; j < maxSeal; j ++) {
if(tempArr[j]) {
result += tempArr[j] * i
} else {
result += 0;
}
}
tempArr.splice(0, maxSeal);
}
}
return result;
}
本地完全ok,赛码上死都通不过,为什么?
#京东内推校招实习社招##京东##笔试题目#