蒟蒻求助 样例过了 0分求调
查看原帖
蒟蒻求助 样例过了 0分求调
1274711
XinyuCraft楼主2025/7/28 14:13
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cout.tie(0), cin.tie(0)
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5 + 1;
int ans = 0;
struct node
{
    int price;
    int t;
    bool isUsed;
};
vector<node> a;
int l = 1,r = 1;
int main(){
    // freopen("transfer.in","r",stdin);
    // freopen("transfer.out","w",stdout);
    int n;
    cin >>n;
    a.resize(n+1);
    for(int i = 1;i<=n;i++){
        node tmp;
        int type;
        cin >>type>>tmp.price>>tmp.t;
        if(type == 0){
            tmp.isUsed = false;
            a[r++] = tmp;
            ans += tmp.price;
        }
        else{
            for(int j = l;j <= r;j++){
                if(tmp.t - a[j].t > 45){
                    l++;
                }
            }
            if(l <= r){
                for(int j = r;j>=l;j--){
                    if(tmp.price <= a[j].price && tmp.t - a[j].t <= 45 && !a[j].isUsed){
                        a[j].isUsed = true;
                    }
                }
            }
            else{
                ans += tmp.price;
            }
        }
    }
    cout <<ans<<endl;
}
2025/7/28 14:13
加载中...