求调!必关!!!小蒟蒻膜拜大佬~~~
查看原帖
求调!必关!!!小蒟蒻膜拜大佬~~~
1339663
stargyh楼主2025/8/2 09:46
#include <bits/stdc++.h>
#define ll long long
#define oi ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;

ll n, way, c, num, to=0;
struct Coupon{int pr, ti;} a[1000005];

int main()
{
  //freopen("xx.in", "r", stdin);
  //freopen("xx.out", "w",stdout);
  oi;
  cin>>n;
    queue <Coupon> coupons;
    int pr, ti;
    for(int i=1;i<=n;i++){
        cin>>way>>pr>>ti;
        
        if(way==0){
            to+=pr;
            coupons.push({pr, ti});
        }else{
            while(!coupons.empty()&&ti-coupons.front().ti>45)
            coupons.pop();  
        }
        bool us=0;
        queue<Coupon>temp;

        while(!coupons.empty()){
            Coupon c=coupons.front();
            coupons.pop();
            if(!us&&c.pr>=pr)
                us=1;
            else temp.push(c);
        }

        while(!temp.empty()){
            coupons.push(temp.front());
            temp.pop();
        }
      if(!us) to+=pr;
    }
    cout<<to<<endl;
      return 0;
}

全WA的 TOT

2025/8/2 09:46
加载中...