CF557A.Ilya and Diplomas
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.
At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.
They also decided that there must be given at least _min_1 and at most _max_1 diplomas of the first degree, at least _min_2 and at most _max_2 diplomas of the second degree, and at least _min_3 and at most _max_3 diplomas of the third degree.
After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.
Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.
It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all n participants of the Olympiad will receive a diploma of some degree.
不久,白俄罗斯将举办一场信息学奥林匹克竞赛,共有 n 名中小学生参加。
在奥赛评审委员会会议上,决定根据参赛学生的成绩,为每位学生颁发一等奖、二等奖或三等奖证书。因此,每位学生将恰好获得一张证书。
会议还决定:一等奖证书的发放数量不得少于 min1 张、不得超过 max1 张;二等奖证书的发放数量不得少于 min2 张、不得超过 max2 张;三等奖证书的发放数量不得少于 min3 张、不得超过 max3 张。
经过进一步讨论,委员会决定:在所有满足上述限制条件的证书分配方案中,优先选择一等奖证书数量最多的方案;在所有一等奖证书数量最多的方案中,再选择二等奖证书数量最多的方案;若仍存在多个方案,则从中选择三等奖证书数量最多的方案。
为证书分配方案选出最优解的任务交给了白俄罗斯最优秀的程序员之一——伊利亚。然而,他找到了更紧要的事情去做,因此现在轮到你来根据上述限制条件,选出最优的证书分配方案。
题目保证:所给限制条件一定存在至少一种满足要求的证书分配方案,使得全部 n 名奥赛参赛者均能获得某一级别的证书。
输入格式
The first line of the input contains a single integer n (3 ≤ n ≤ 3·106) — the number of schoolchildren who will participate in the Olympiad.
The next line of the input contains two integers _min_1 and _max_1 (1 ≤ _min_1 ≤ _max_1 ≤ 106) — the minimum and maximum limits on the number of diplomas of the first degree that can be distributed.
The third line of the input contains two integers _min_2 and _max_2 (1 ≤ _min_2 ≤ _max_2 ≤ 106) — the minimum and maximum limits on the number of diplomas of the second degree that can be distributed.
The next line of the input contains two integers _min_3 and _max_3 (1 ≤ _min_3 ≤ _max_3 ≤ 106) — the minimum and maximum limits on the number of diplomas of the third degree that can be distributed.
It is guaranteed that _min_1 + _min_2 + _min_3 ≤ n ≤ _max_1 + _max_2 + _max_3.
输入的第一行包含一个整数 n(3≤n≤3⋅106)—— 将参加奥林匹克竞赛的学生人数。
输入的第二行包含两个整数 min1 和 max1(1≤min1≤max1≤106)—— 第一等级证书可颁发数量的最小值和最大值。
输入的第三行包含两个整数 min2 和 max2(1≤min2≤max2≤106)—— 第二等级证书可颁发数量的最小值和最大值。
输入的第四行包含两个整数 min3 和 max3(1≤min3≤max3≤106)—— 第三等级证书可颁发数量的最小值和最大值。
保证满足 min1+min2+min3≤n≤max1+max2+max3。
输出格式
In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas.
The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first degree. Of all the suitable options, the best one is the one which maximizes the number of participants who receive diplomas of the second degree. If there are several of these options, the best one is the one that maximizes the number of diplomas of the third degree.
在输出的第一行中,打印三个数字,分别表示在最优的证书分配方案下,获得第一、第二和第三等级证书的学生人数。
最优的证书分配方案是指使获得第一等级证书的学生人数最多的方案。在所有满足该条件的方案中,最优方案是使获得第二等级证书的学生人数最多的方案。若仍存在多个满足条件的方案,则其中使获得第三等级证书的学生人数最多的方案为最优方案。
输入输出样例
输入#1
6 1 5 2 6 3 7
输出#1
1 2 3
输入#2
10 1 2 1 3 1 5
输出#2
2 3 5
输入#3
6 1 3 2 2 2 2
输出#3
2 2 2
输入解题思路,AI测评打分。不知道怎么写?