0分求助
查看原帖
0分求助
1271781
zhangchenyi_awa楼主2025/1/6 22:39
#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
    int s=0,w=1;
    char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') {
            w=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        s=s*10+c-'0';
        c=getchar();
    }
    x=s*w;
    return;
}
int n;
struct node {
    int price,time;
    bool flag;
} bus[100010];
int bus_;
int op;
int money;
int m,t;
int main() {
    read(n);
    for(int i=1; i<=n; i++) {
        read(op);
        read(m);
        read(t);
        if(op==0) {
            money+=m;
            bus[++bus_].price=m;
            bus[bus_].time=t;
            bus[bus_].flag=false;
        } else {
            int MIN2=-1;
            for(int j=bus_; j>=1; j--) {
                if(bus[j].time<t-45) {
                    break;
                }
                if(bus[j].flag==false&&bus[j].price>=m) {
                    MIN2=j;
                }
            }
            if(MIN2==-1) {
                money+=m;
            } else {
                bus[MIN2].flag=false;
            }
        }
    }
    printf("%d",money);
    return 0;
}

小号悬赏关注

2025/1/6 22:39
加载中...