题解
2023-08-19 18:22:18
发布于:广东
13阅读
0回复
0点赞
短小精悍
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100010;
long long ans;
struct node{
int s_b;
long long price, t, ts, tprice;
} a[maxn];
int main(){
int n, j = 1, t = 1;
cin>>n;
for(int i=1; i<=n; i++){
cin >> a[i].s_b >> a[i].price >> a[i].t;
if(a[i].s_b == 0){
ans += a[i].price;
a[j].ts = a[i].t + 45;
a[j].tprice = a[i].price;
++j;
}else{
int k;
for(k=1; k<j; k++){
if(a[k].ts != -1 ){
if(a[k].ts < a[i].t){
a[k].ts = -1;
}
if(a[k].ts >= a[i].t && a[k].tprice >= a[i].price){
a[k].ts = -1;
break;
}
}
}
if( k == j){
ans += a[i].price;
}
}
}
cout<<ans;
return 0;
}
这里空空如也
有帮助,赞一个