10pts AC#1求助
查看原帖
10pts AC#1求助
1183074
xzy_AK_IOI楼主2024/8/3 19:58
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
	int id;
	int Time;
	int tim;
	int first;
};
bool operator < (const node& a,const node& b){
	if (a.first!=b.first) return a.first<b.first;
	return a.Time>b.Time;
}
priority_queue <node> Q;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,d;
	int ti;
	while (cin>>a>>b>>c>>d){
		if (Q.empty()){
			Q.push((node){a,b,c,d});
			ti=b;
			continue;
		}
		int t=b-ti;
		while (Q.size() && t>=Q.top().tim){
			cout<<Q.top().id<<" "<<ti+Q.top().tim<<'\n';
			t-=Q.top().tim;
			Q.pop();
		}
		if (Q.size()){
			node f;
			f=Q.top();
			Q.pop();
			f.tim-=t;
			Q.push(f);
		}
		ti=b;
		Q.push((node){a,b,c,d});
	}
	while (Q.size()){
		cout<<Q.top().id<<" "<<ti+Q.top().tim<<'\n';
		ti+=Q.top().tim;
		Q.pop();
	}
	return 0;
}
/*
1 1 5 3
2 10 5 1
3 12 7 2
4 20 2 3
5 21 9 4
6 22 2 4
7 23 5 2
8 24 2 4
9 100000 41234141 0
0 0 0 0 
*/
2024/8/3 19:58
加载中...