题目解析
本题应该就是逻辑分析题。
具体解析请看代码注释,已为代码添加详细注释。
JS算法源码
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const pubs = parse(await readline());
const subs = parse(await readline());
// 按照发布时间升序
pubs.sort((a, b) => a[0] - b[0]);
// 记录每个订阅者收到的内容
const contents = [];
for (let i = 0; i < subs.length; i++) contents.push([]);
// 遍历发布消息
for (let [pubTime, pubContent] of pubs) {
// 发布的消息会被发送到订阅的消费者中优先级最高
// 输入中订阅者按优先级升序排列, 因此后面的订阅者优先级更高, 因此这里倒序
for (let j = subs.length - 1; j >= 0; j--) {
const [start, end] = subs[j

已下架不支持订阅
612






