#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,m,n) for(int i=m;i<=n;i++)
using namespace std;
const int N=100005;
long long n,p[N],t[N],ans,cnt1=1,cnt2=1,tic;
bool a[N],flag;
struct node{
int pr,en,be;
}tt[N];
int main(){
cin>>n;
rep(i,1,n){
cin>>a[i]>>p[i]>>t[i];
if(a[i]==true){
tt[cnt2].pr =p[i];
tt[cnt2].be =t[i];
cnt2++;
}
else{
ans+=p[i];
tic++;
tt[cnt1].en =t[i]+45;
cnt1++;
}
}
rep(i,1,max(cnt1,cnt2)){
if(tic){
if(tt[i].en >=tt[i].be ){
tic--;
}
else{
tic--;
int ticc=tic;
rep(j,i,ticc){
if(tt[j].en >=tt[i].be ){
flag=true;
tic--;
break;
}
else{
tic--;
continue;
}
}
if(flag==false){
ans+=tt[i].pr ;
}
}
}
else{
ans+=tt[i].pr ;
}
}
cout<<ans<<endl;
return 0;
}
觉得没有什么问题,但是样例1都没过,少算了6,不明白漏了哪里