CF1185C1.Exam in BerSU (easy version)

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn students. Students will take the exam one-by-one in order from 11-th to nn-th. Rules of the exam are following:

  • The ii-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 tit_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 MM minutes (max⁡ti≤M\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 ii, you should count the minimum possible number of students who need to fail the exam so the ii-th student has enough time to pass the exam.

For each student ii, find the answer independently. That is, if when finding the answer for the student i1i_1 some student jj should leave, then while finding the answer for i2i_2 (i2>i1i_2 \gt i_1) the student jj student does not have to go home.

简单版本与困难版本的唯一区别在于约束条件。

贝尔兰国立大学的一场考试已经开始,许多学生正在参加考试。

波利格拉夫·波利格拉福维奇将对一组 nn 名学生进行考核。学生们将按编号从第 11 位到第 nn 位依次参加考试。考试规则如下:

  • 第 ii 位学生随机抽取一道考题;
  • 若该考题对该学生而言过于困难,则他不作答并立即离场(此过程极快,视为不消耗任何时间),该学生考试不及格;
  • 若该学生认为考题简单,则他恰好花费 tit_i 分钟完成考试;完成后他立即获得成绩并离场。

学生们严格按照既定顺序依次考试,中间无任何中断。在任意时刻,波利格拉夫·波利格拉福维奇仅接收一名学生的作答。

整场考试的总时长为 MM 分钟(满足 max⁡ti≤M\max t_i \le M),因此排在队列末尾的学生更有可能因时间不足而无法完成考试。

对于每位学生 ii,你需要计算:为确保第 ii 位学生有足够时间完成考试,最少需要有多少名学生考试不及格(即提前离场)。

对每位学生 ii,需独立求解该问题。即:当为学生 i1i_1 求解答案时,若某学生 jj 需要离场,则在为学生 i2i_2(其中 i2>i1i_2 > i_1)求解答案时,学生 jj 并不必然需要离场。

输入格式

The first line of the input contains two integers nn and MM (1≤n≤1001 \le n \le 100, 1≤M≤1001 \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 nn integers tit_i (1≤ti≤1001 \le t_i \le 100) — time in minutes that ii-th student spends to answer to a ticket.

It's guaranteed that all values of tit_i are not greater than MM.

输入的第一行包含两个整数 nn 和 MM(1≤n≤1001 \le n \le 100,1≤M≤1001 \le M \le 100)—— 分别表示学生人数和考试总时长(单位:分钟)。

输入的第二行包含 nn 个整数 tit_i(1≤ti≤1001 \le t_i \le 100)—— 表示第 ii 位学生回答一道考题所花费的时间(单位:分钟)。

保证所有 tit_i 的值均不超过 MM。

输出格式

Print nn numbers: the ii-th number must be equal to the minimum number of students who have to leave the exam in order to ii-th student has enough time to pass the exam.

输出 nn 个数:其中第 ii 个数必须等于为使第 ii 个学生有足够时间通过考试而必须离开考场的学生的最少人数。

输入输出样例

  • 输入#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=15M=15 (the sum is 1+2+3+4+5=151+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 00.

In order for the 66-th student to pass the exam, it is necessary that at least 22 students must fail it before (for example, the 33-rd and 44-th, then the 66-th will finish its exam in 1+2+5+6=141+2+5+6=14 minutes, which does not exceed MM).

In order for the 77-th student to pass the exam, it is necessary that at least 33 students must fail it before (for example, the 22-nd, 55-th and 66-th, then the 77-th will finish its exam in 1+3+4+7=151+3+4+7=15 minutes, which does not exceed MM).

示例 1 的解释。

请注意,前五位学生的考试时间之和不超过 M=15M=15(该和为 1+2+3+4+5=151+2+3+4+5=15)。因此,即使在他们之前的所有学生都通过了考试,前五位学生仍能通过考试。换言之,答案中前五个数字均为 00。

为了让第 66 位学生通过考试,必须至少有 22 位学生在此之前未能通过考试(例如第 33 位和第 44 位学生未通过,则第 66 位学生将在 1+2+5+6=141+2+5+6=14 分钟内完成考试,未超过 MM)。

为了让第 77 位学生通过考试,必须至少有 33 位学生在此之前未能通过考试(例如第 22、55 和 66 位学生未通过,则第 77 位学生将在 1+3+4+7=151+3+4+7=15 分钟内完成考试,未超过 MM)。

输入解题思路,AI测评打分。不知道怎么写?

首页