写了接近半小时,最后20个点全RE,崩溃了
新手,大佬勿喷
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll tp[10001],price[10001],tme[10001];
struct node{
long long pc,t;
bool flag;
};
int main(){
int n;
cin>>n;
vector<node>ticket;
int ticket_tc=0;
ll total_price=0;
int i,j;
for(i=0;i<n;i++){
cin>>tp[i]>>price[i]>>tme[i];
if(tp[i]==0){
ticket[ticket_tc].pc = price[i];
ticket[ticket_tc].t = tme[i];
ticket[ticket_tc].flag = true;
ticket_tc++;
total_price+=price[i];
}
if(tp[i]==1){
if(ticket_tc!=0){
bool use_ticket = false;
for(j=0;j<ticket_tc;j++){
if((price[i]<=ticket[j].pc)&&(tme[i]-ticket[j].t<=45)){
if(ticket[j].flag == true){
use_ticket = true;
ticket[j].flag = false;
break;
}
}
}
if(use_ticket){
continue;
}
else{
total_price+=price[i];
}
}
}
}
cout<<total_price<<endl;
return 0;
}