必看 求关注求赞
2025-08-12 21:42:09
发布于:山东
6阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
struct node{
int c;
int q;
int s;
}a[N];
int main(){
int n;
cin >> n;
long long ans=0;
int m=0;
for(int i = 1; i <= n; i++){
int c,q,s;
cin>>c>>q>>s;
if(c==0){
ans+=q;
m++;
a[m].q = q;
a[m].s = s+45;
}else{ //公交车
bool flg=true;
int j=m;
int id=-1;
while(j>=1){
if(a[j].s<s)
break;
if(a[j].q>=q){
id=j;
flg=false;
}
j--;
}
if(flg)
ans+=q;
else{
a[id].q=0;
}
}
}
cout<<ans<<endl;
return 0;
}
这里空空如也
有帮助,赞一个