CF1439C.Greedy Shopping
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an of integers. This array is non-increasing.
Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost of a meal in the i -th shop is equal to ai .
You should process q queries of two types:
- 1 x y: for each shop 1≤i≤x set ai=max(ai,y) .
- 2 x y: let's consider a hungry man with y money. He visits the shops from x -th shop to n -th and if he can buy a meal in the current shop he buys one item of it. Find how many meals he will purchase. The man can buy a meal in the shop i if he has at least ai money, and after it his money decreases by ai .
输入格式
The first line contains two integers n , q ( 1≤n,q≤2⋅105 ).
The second line contains n integers a1,a2,…,an (1≤ai≤109) — the costs of the meals. It is guaranteed, that a1≥a2≥…≥an .
Each of the next q lines contains three integers t , x , y ( 1≤t≤2 , 1≤x≤n , 1≤y≤109 ), each describing the next query.
It is guaranteed that there exists at least one query of type 2 .
输出格式
For each query of type 2 output the answer on the new line.
输入输出样例
输入#1
10 6 10 10 10 6 6 5 5 5 3 1 2 3 50 2 4 10 1 3 10 2 2 36 1 4 7 2 2 17
输出#1
8 3 6 2
说明/提示
In the first query a hungry man will buy meals in all shops from 3 to 10 .
In the second query a hungry man will buy meals in shops 4 , 9 , and 10 .
After the third query the array a1,a2,…,an of costs won't change and will be {10,10,10,6,6,5,5,5,3,1} .
In the fourth query a hungry man will buy meals in shops 2 , 3 , 4 , 5 , 9 , and 10 .
After the fifth query the array a of costs will be {10,10,10,7,6,5,5,5,3,1} .
In the sixth query a hungry man will buy meals in shops 2 and 4 .