DPS * N = (NormalDamage + CritDamage) * AttackSpeed * N
- (NormalDamage + CritDamage)
+ (NormalDamage + CritDamage) * SuperDamageMultiplier
= (NormalDamage + CritDamage) * (AttackSpeed * N - 1 + SuperDamageMultiplier)
DPS = (NormalDamage + CritDamage) * (AttackSpeed + (SuperDamageMultiplier - 1) / N)
function intervals($arr) {
$start = -1;
$end = -1;
$result = [];
foreach ($arr as $val) {
if ($start === -1) {
$start = $val;
$end = $val;
} elseif ($val === $end + 1) {
$end = $val;
} else {
$result[] = ['start' => $start, 'end' => $end];
$start = $val;
$end = $val;
}
}
if ($start !== -1) {
$result[] = ['start' => $start, 'end' => $end];
}
return $result;
}
print_r(intervals([0,1,2,3,6,7,8,9,12,13,14,15]));
// Array (
// [0] => Array (
// [start] => 0
// [end] => 3
// )
// [1] => Array (
// [start] => 6
// [end] => 9
// )
// [2] => Array (
// [start] => 12
// [end] => 15
// )
// )
function allTestsTime(numDevices, testTimes) {
testTimes.sort((a, b) => b - a);
let totalTime = 0;
for (let i = 0; i < testTimes.length; i++) {
totalTime += testTimes[i] * (2 * Math.floor(i / numDevices) + 1);
}
return totalTime;
}
console.log(allTestsTime(3, [6, 2, 5]));
// 13