TREEMAP is sorted according to Key and Value

2022-12-26   ES  

Original port transfer door
Use the pile simulation operating system


#include <bits/stdc++.h>
#define maxn 1000010
using namespace std;
struct heap{
	int id, st, t, level;
	bool operator < (const heap &x) const {
     return x.level == level ? < st : x.level > level; }
priority_queue <heap> q;
int id[maxn], st[maxn], t[maxn], level[maxn], n;

int main(){
	freopen("1.txt", "r", stdin);
	while (~scanf("%d%d%d%d", &id[n + 1], &st[n + 1], &t[n + 1], &level[n + 1])) ++n;
	st[n + 1] = 2e9;
	for (int i = 1; i <= n; ++i){
    id[i], st[i], t[i], level[i]});
		int s = st[i];
		while (!q.empty()){
			heap tmp =; q.pop();
			if (tmp.t <= st[i + 1] - s) s += tmp.t, printf("%d %d\n",, s);
     tmp.t -= (st[i + 1] - s); q.push(tmp); break; }
	return 0;


Related Posts

CAMUNDA and Spring Boot Integration (3)-Camunda Engine Properties DEMI

WMI009-WMI Learning Notes (9) -System.Management and System.Management.Instrumentation namespaces (name space)

wgs84 Earth coordinate system, GCJ02 Mars coordinate system, BD09 Baidu coordinate system profile and conversion

multi -step progress bar implementation method

TREEMAP is sorted according to Key and Value

Random Posts

IOS integrates Charts drawing a chart framework in OC project

MFC+OpenCV3.3.1+Display image video+water level recognition

“Programmer Installation B Guide”

Comparison of C/C ++ LOG library

[Leveldb] Cache (18): BlockCache