작성
·
155
0
function solution(budget, priceArr) {
let count = 0;
priceArr.sort((arr1, arr2) => (arr1[0] + arr1[1]) - (arr2[0] + arr2[1]));
for (const index in priceArr) {
if (budget - priceArr[index][0] + priceArr[index][1] > 0) {
budget -= priceArr[index][0] + priceArr[index][1];
count++;
} else if (budget - (priceArr[index][0] / 2) + priceArr[index][1] > 0) {
count++;
break;
} else {
break;
}
}
return count;
}
답변 1
1
안녕하세요^^
반례입니다. 답은 2입니다.
답변 감사합니다!