306367: CF1185C2. Exam in BerSU (hard version)
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Exam in BerSU (hard version)
题意翻译
这题与$CF1185C1$不同的只有数据范围~~当然难度也会增大~~。 如果用$Python$提交的话,那么改用$PyPy$交可以加快运行时间。 题意与$CF1185C1$相同,点击[这里](https://www.luogu.org/problem/CF1185C1)查看题面。 该题当中,$1\leqslant n\leqslant 2*10^5,1\leqslant\max t_i\leqslant m\leqslant2*10^7$。题目描述
The only difference between easy and hard versions is constraints. If you write a solution in Python, then prefer to send it in PyPy to speed up execution time. 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 2 \cdot 10^5 $ , $ 1 \le M \le 2 \cdot 10^7 $ ) — 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 $ .
输出格式
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