文章

246

粉丝

0

获赞

1202

访问

193.6k

头像
排队打饭 题解:

#include<iostream>
using namespace std;

const int N=1e5+10;

struct stu{
    int a_time,u_time,t_time;
};

stu st[N];
int n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>st[i].a_time>>st[i].u_time>>st[i].t_time;
    cout<<st[1].a_time<<" ";
    int c_time=st[1].a_time+st[1].u_time;
    for(int i=2;i<=n;i++)
    {
        if(c_time-st[i].a_time>st[i].t_time)
        cout<<-1<<" ";
        else
        {
            cout<<c_time<<" ";
            c_time+=st[i].u_time;
        }
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发