第一题 JavaScript 版: function method(arr) { arr.sort((a, b) => { if (a[0] !== b[0]) return b[0] - a[0]; return a[1] - b[1]; }); let res = arr[0][0]; arr.shift(); for (const boss of arr) { res -= boss[1]; if (res < boss[0]) res = boss[0]; } return res; } let n = readInt(); const list = []; while (n--) { const row = read_line().trim().split(' ').map(item => parseInt(item)); list.push(row); } print(method(list));

相关推荐

自学java狠狠赚一...:骗你点star的,港卵公司,记得把star收回去
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务