度度熊的工作
问题描述:老板给嘟嘟熊分配了n个工作,第i个工作需要消费a单位的事件,每个工作必须在老板给定的时间限制b之内完成。度度熊从0时刻开始工作,在同一时间度度熊只能做一件工作,度度熊想知道他是否能把所有工作完成?
输入例子:
1
5
2 4
1 9
1 8
4 9
3 12
输出:Yes
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
let t = await readline(); // 数组数
while (t--) {
let flag = true;
let n = await readline(); // 数组的个数
while (n--) {
let arr = (await readline()).split(" ");
if (parseInt(arr[0]) > parseInt(arr[1])) {
flag = false;
}
}
if (flag) {
console.log("Yes");
} else {
console.log("No");
}
}
})();