文章

12

粉丝

0

获赞

12

访问

619

头像
排队打饭 题解:
P997 复旦大学2020年机试题
发布于2026年2月27日 16:32
阅读数 15

#include<bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin>>n;
	long long free_time = 0;
	for(int i = 0 ; i < n; i++){
		long long a,b,t;
		cin>>a>>t>>b;
		
		long long start_time = max(a,free_time);
		if(start_time > a+b){
			cout<<-1<<' ';
		}
		else{
			cout<<start_time<<' ';
			free_time = start_time + t;
		}
		
		
	}
	cout<<'\n';
	
	
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发