如题。。。
直达链接:
公交换乘
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=100010;
struct TKT{
int tim,price;
}st[maxn];
int n,top=0,tail=1,ans=0;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(!x){
st[++top].tim=z;
st[top].price=y;
ans+=y;
}
else{
bool free=0;
for(int i=tail;i<=top;i++){
if(z-st[i].tim>45) tail++;
else if(st[i].price>=y){
free=1;
st[i].tim=-maxn;
break;
}
}
if(!free) ans+=y;
}
}
printf("%d\n",ans);
return 0;
}