- 模拟就是了,不就是个蓝吗?
A few moments later...
-
WTF??为什么这里不对?
-
哦应该先算这个
-
??为什么样例还是过不了
-
原来这个要重置
-
为什么样例过了却RE
-
数组开小了 ...
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1000005
struct node
{
ll num, arr, tim, pri;
};
node a[N];
bool operator < (node a1, node a2)
{
if(a1.pri != a2.pri)
{
return a1.pri < a2.pri;
}
return a1.num > a2.num;
}
priority_queue<node> q;
ll tot = 0, Time = 0;
int main()
{
while(tot++, scanf("%lld%lld%lld%lld", &a[tot].num, &a[tot].arr, &a[tot].tim, &a[tot].pri) != EOF)
{
while(!q.empty() && Time + q.top().tim <= a[tot].arr)
{
Time += q.top().tim;
printf("%lld %lld\n", q.top().num, Time);
q.pop();
}
if(!q.empty())
{
node u = q.top();
q.pop();
u.tim = u.tim - a[tot].arr + Time;
q.push(u);
}
q.push(a[tot]);
Time = a[tot].arr;
}
while(!q.empty())
{
printf("%lld %lld\n", q.top().num, Time + q.top().tim);
Time += q.top().tim;
q.pop();
}
return 0;
}