307944: CF1439C. Greedy Shopping
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Greedy Shopping
题意翻译
给定一个大小为 $n$ 的**非升序列** $a$ 。 现在有两类操作, ```1 x y``` , $\forall i\in[1,x],a_i=\max(a_i,y).$ ```2 x y``` , 从下标 $x$ 开始,从左往右访问序列 $a$ ,如果 $a_i\le y$ ,则 $\text{answer}++,y=y-a_i$ 。 对于每一次操作 $2$ ,输出 $\text{answer}$ 。题目描述
You are given an array $ a_1, a_2, \ldots, a_n $ 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 $ a_i $ . You should process $ q $ queries of two types: - 1 x y: for each shop $ 1 \leq i \leq x $ set $ a_{i} = max(a_{i}, 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 $ a_i $ money, and after it his money decreases by $ a_i $ .输入输出格式
输入格式
The first line contains two integers $ n $ , $ q $ ( $ 1 \leq n, q \leq 2 \cdot 10^5 $ ). The second line contains $ n $ integers $ a_{1},a_{2}, \ldots, a_{n} $ $ (1 \leq a_{i} \leq 10^9) $ — the costs of the meals. It is guaranteed, that $ a_1 \geq a_2 \geq \ldots \geq a_n $ . Each of the next $ q $ lines contains three integers $ t $ , $ x $ , $ y $ ( $ 1 \leq t \leq 2 $ , $ 1\leq x \leq n $ , $ 1 \leq y \leq 10^9 $ ), 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