A12723 | Exam in BerSU (easy version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The only difference between easy and hard versions is constraints.
A session has begun at Beland State University. Many students are taking exams.
Polygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$ -th to $n$ -th. Rules of the exam are following:
- The $i$ -th student randomly chooses a ticket.
- if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.
- if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home.
Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.
The duration of the whole exam for all students is $M$ minutes ( $\max t_i \le M$ ), so students at the end of the list have a greater possibility to run out of time to pass the exam.
For each student $i$ , you should count the minimum possible number of students who need to fail the exam so the $i$ -th student has enough time to pass the exam.
For each student $i$ , find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ( $i_2>i_1$ ) the student $j$ student does not have to go home.
A session has begun at Beland State University. Many students are taking exams.
Polygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$ -th to $n$ -th. Rules of the exam are following:
- The $i$ -th student randomly chooses a ticket.
- if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.
- if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home.
Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.
The duration of the whole exam for all students is $M$ minutes ( $\max t_i \le M$ ), so students at the end of the list have a greater possibility to run out of time to pass the exam.
For each student $i$ , you should count the minimum possible number of students who need to fail the exam so the $i$ -th student has enough time to pass the exam.
For each student $i$ , find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ( $i_2>i_1$ ) the student $j$ student does not have to go home.
输入格式
The first line of the input contains two integers $n$ and $M$ ( $1 \le n \le 100$ , $1 \le M \le 100$ ) — the number of students and the total duration of the exam in minutes, respectively.
The second line of the input contains $n$ integers $t_i$ ( $1 \le t_i \le 100$ ) — time in minutes that $i$ -th student spends to answer to a ticket.
It's guaranteed that all values of $t_i$ are not greater than $M$ .
The second line of the input contains $n$ integers $t_i$ ( $1 \le t_i \le 100$ ) — time in minutes that $i$ -th student spends to answer to a ticket.
It's guaranteed that all values of $t_i$ are not greater than $M$ .
输出格式
Print $n$ numbers: the $i$ -th number must be equal to the minimum number of students who have to leave the exam in order to $i$ -th student has enough time to pass the exam.
输入输出样例
输入 #1
7 15 1 2 3 4 5 6 7
输出 #1
0 0 0 0 0 2 3
输入 #2
5 100 80 40 40 40 60
输出 #2
0 1 1 2 3
The explanation for the example 1.
Please note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$ ). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$ .
In order for the $6$ -th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$ -rd and $4$ -th, then the $6$ -th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$ ).
In order for the $7$ -th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$ -nd, $5$ -th and $6$ -th, then the $7$ -th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$ ).
Please note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$ ). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$ .
In order for the $6$ -th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$ -rd and $4$ -th, then the $6$ -th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$ ).
In order for the $7$ -th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$ -nd, $5$ -th and $6$ -th, then the $7$ -th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$ ).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted