求助 0分WA!(急)
查看原帖
求助 0分WA!(急)
494699
卷王慢即快楼主2022/12/25 13:07
#include <bits/stdc++.h>
using namespace std;
int n = 1;
long long sum = 0;
struct node
{
	int num, start, time, pri;
    bool operator<(const node &a) const
    {
		if(a.pri != pri) return a.pri < pri;
		return a.start > start;
    }
}a[500001];
node t;
priority_queue<node> q;
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return x * f;
}
int main()
{
	while(cin >> t.num >> t.start >> t.time >> t.pri)
	{
		while(!q.empty() && sum + q.top().time <= t.start)
		{
			node u = q.top(); q.pop();
			sum += u.time;
			printf("%d %ld\n", u.num, sum);
		}
		if(!q.empty())
		{
			node u = q.top(); q.pop();
			u.time = u.time - t.start + sum;
			q.push(u);
		}
		q.push(t);
		sum = t.time;
	}
	while(!q.empty())
	{
		node u = q.top(); q.pop();
		sum += u.time;
		printf("%d %ld\n", u.num, sum);
	}
	return 0;
}
2022/12/25 13:07
加载中...