A9890 | Ilya and Diplomas
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The first line of the input contains a single integer $n$ ( $3<=n<=3·10^{6}$ ) — 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}<=10^{6}$ ) — 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}<=10^{6}$ ) — 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}<=10^{6}$ ) — 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}$ .
The next line of the input contains two integers $min_{1}$ and $max_{1}$ ( $1<=min_{1}<=max_{1}<=10^{6}$ ) — 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}<=10^{6}$ ) — 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}<=10^{6}$ ) — 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}$ .
输出格式
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted