A1121 | [COCI-2007_2008-contest4]#3 MUZICARI
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
"The Drinking Musicians", a widely known and popular folk group, are coming to your town. The musicians are known not only by their playing skills, but also their rough character. They never arrive on time, don't know which town they're in, and frequently have trouble finding the stage.
Additionally, during the concert, each of the musicians at one point takes a break. If three or more of them are on a break at the same time, they start stirring trouble in town and the rest of the group start panicking and playing the wrong chords.
The concert will be T minutes long, during which each of the N members will take a break. The length of the break is known for each member.
Help the organizer of the concert by writing a program that determines how to schedule the breaks of the member so that, at any given moment, at most two are absent from the stage. All breaks must be entirely during the concert.
Additionally, during the concert, each of the musicians at one point takes a break. If three or more of them are on a break at the same time, they start stirring trouble in town and the rest of the group start panicking and playing the wrong chords.
The concert will be T minutes long, during which each of the N members will take a break. The length of the break is known for each member.
Help the organizer of the concert by writing a program that determines how to schedule the breaks of the member so that, at any given moment, at most two are absent from the stage. All breaks must be entirely during the concert.
输入格式
The first line of input contains the integers T and N (1 ≤ T ≤ 5000, 1 ≤ N ≤ 500), the length of the concert in minutes and the number of musicians in the group.
The next line contains N integers separated by single spaces, the length of the break in minutes for each member.
Note: The input data will be such that a solution, although not necessarily unique, will always exist.
The next line contains N integers separated by single spaces, the length of the break in minutes for each member.
Note: The input data will be such that a solution, although not necessarily unique, will always exist.
输出格式
For each musician output one integer, the number of minutes the musician will spend on stage before going on the break.
Output the musicians in the same order they were given in the input.
Output the musicians in the same order they were given in the input.
输入输出样例
输入 #1
8 3 4 4 4
输出 #1
0 2 4
输入 #2
10 5 7 5 1 2 3
输出 #2
3 3 9 0 0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted