为什么错了???
查看原帖
为什么错了???
413858
皮卡丘pika楼主2020/10/31 14:43

WHAT!!!

#include <iostream>
#include <cstdio>
using namespace std;
struct note
{
    bool kind;
    int time;
    int price;
};
note a[100001];
int n;
int head=0,tail=0;
note r[100001];
void push(note x)
{
    a[tail]=x;
    tail++;
}
note check()
{
    return a[head];
}
void pop()
{
    head++;
}
int ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>r[i].kind>>r[i].price>>r[i].time;
    for(int i=1;i<=n;i++)
    {
        if(r[i].kind==false)
        {
            push(r[i]);
            ans+=r[i].price;
        }
        else
        {
            while((r[i].time-check().time)<45&&head<=tail)
            {
                pop();
            }
            bool flag=false;
            for(int j=head;j<tail;j++)
            {
                if((a[j].price>=r[i].price)&&(r[i].time-a[j].time)<=45)
                {
                    flag=true;
                    a[j].time=-999;
                    break;
                }
            }
            if(flag==false) ans+=r[i].price;
        }
    }
    cout<<ans;
    return 0;
}

**

2020/10/31 14:43
加载中...