【aec-online-i-2021】真题挑战!!!

发布于:2022-12-10 ⋅ 阅读:(137) ⋅ 点赞:(0)

Problem A. Busiest Computing Nodes

Input file: standard input
Output: standard output
Time limit: 1 second
Memory limit: 256 megabytes

You have a computing cluster with a total of k computing nodes , labelled from 0 to k-1 . The cluster can handle multiple requests at the same time , but each node can process at most one request at the same time .
The rules for request assignment to computing nodes are as follows . Assume the i-th(i starts from 0)request arrives .IF all nodes are occupied, the request is discarded(not processed at all). IF the (i%k)-th node is available , it will process the request . Otherwise, the request will check the availability of the next node at (i+1)%k , (i+2)%k,and so on , until it finds an idle node.
Given a set of request with their arrival time and the processing time , your task is to find the busiest computing nodes . A node that belongs to the busiest nodes when no other nodes serve more requests than it nodes .

Input

The first line includes k and n , representing the size of the cluster and the number of requests.
Each of the next n lines includes two positive integers , representing the arrival time and the processing time of a request .
The input data satisfy that 1<=k , n < = 100,000,and 1<=arrival_time,processing_time <=1,000,000,000.
The requests are given in non-decreasing order of arrival time.

Output

Print the labels of all the busiest nodes in lexicographic order, separated by spaces.

Example

standard input standard output
3 5 1
1 5
2 2
3 3
4 3
5 3

这是去年参加ACM网络赛的真题,昨天收拾东西收拾出来了,第一次参加正儿八经的比赛,还是有很多不足的地方。

欢迎大家来我的评论区做题呀❤!!!

我先把这个题目翻译一下:

你有一个计算集群,总共有k个计算节点,标记为从0到k-1。集群可以同时处理多个请求,但每个节点最多可以同时处理一个请求。
分配给计算节点的请求规则如下。假设第i个(i从0开始)请求到达。如果所有节点都被占用,则丢弃该请求(根本不处理)。如果第(i%k)个节点可用,它将处理该请求。否则,请求将在(i+1)%k、(i+2)%k等位置查找下一个节点的可用性,直到找到空闲节点。
给定一组请求及其到达时间和处理时间,你的任务是查找最忙的计算节点。当没有其他节点提供比其节点更多的请求时,属于最忙节点的节点。

输入

第一行包括k和n,表示集群的大小和请求数。
接下来的n行中的每一行都包含两个正整数,表示请求的到达时间和处理时间。
输入数据满足1<=k,n<=100000,以及1<=arrival_time,processing_time<=1000000000。
请求以到达时间的升序排序给出。

输出

按词典顺序输出所有最繁忙节点的标签,并用空格分隔。

欢迎大家来我的评论区做题呀❤!!!

本文含有隐藏内容,请 开通VIP 后查看