题目:P5661 [CSP-J 2019] 公交换乘
die码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
ll way,cost,_time;
}tmp;
ll n,price=0;
queue<node>q;
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld%lld%lld",&tmp.way,&tmp.cost,&tmp._time);
if(tmp.way==0){
q.push(tmp);
price+=tmp.cost;
}else{
node _free=q.front();
if(_free.cost>=tmp.cost&&tmp._time-_free._time<=45){
q.pop();
}else{
price+=tmp.cost;
}
while(tmp._time-q.front()._time>45) q.pop();
}
}
printf("%lld",price);
return 0;
}