CE求助
  • 板块学术版
  • 楼主memset_0x3f
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/7/10 21:21
  • 上次更新2023/10/27 21:10:38
查看原帖
CE求助
333478
memset_0x3f楼主2022/7/10 21:21

link

代码莫名其妙报错,VSCode没有检测出来语法错误,但一编译运行就会炸掉。

Code\texttt{Code}

#include <bits/stdc++.h>

using namespace std;

struct Node {
	int id, ret, wkt, pri;
	bool operator < (Node x) {
		return !(pri != x.pri ? pri > x.pri : ret < x.ret);
	}
};

signed main() {
	priority_queue<Node> pq;
	Node now;
	int sum = 0;
	while (~scanf("%d%d%d%d", &now.id, &now.ret, &now.wkt, &now.pri)) {
		while (!pq.empty() && sum + pq.top().wkt <= now.ret) {
			printf("%d %d\n", pq.top().id, sum + pq.top().wkt);
			sum += pq.top().wkt;
			pq.pop();
		}
		if (!pq.empty()) {
			Node tmp = pq.top();
			pq.pop();
			tmp.wkt -= now.ret - sum;
			pq.push(tmp);
		}
		pq.push(now);
		sum = now.ret;
	}
	while (!pq.empty()) {
		printf("%d %d\n", pq.top().id, sum += pq.top().wkt);
		// cout << "QWQ:" << pq.size() << '\n';
		pq.pop();
	}
	return 0;
}
2022/7/10 21:21
加载中...