2017ccpc 杭州Master of Sequence

Problem K. Master of Sequence
Therearetwosequencesa1,a2,··· ,an, b1,b2,··· ,bn. LetS(t) =∑n i=1⌊t−bi ai ⌋. Therearemoperationswithin three kinds as following: • 1 x y: change value ax to y. • 2 x y: change value bx to y. • 3 k: ask min{t|k ≤ S(t)} Input The first line contains a integer T (1 ≤ T ≤ 5) representing the number of test cases. For each test case, the first line contains two integers n (1 ≤ n ≤ 100000), m (1 ≤ m ≤ 10000). The following line contains n integers representing the sequence a1,a2,··· ,an. The following line contains n integers representing the sequence b1,b2,··· ,bn. The following m lines, each line contains two or three integers representing an operation mentioned above. It is guaranteed that, at any time, we have 1 ≤ ai ≤ 1000, 1 ≤ bi,k ≤ 109. And the number of queries (type 3 operation) in each test case will not exceed 1000.
Output For each query operation (type 3 operation), print the answer in one line.

分析:

b的范围只有1000,于是树状数组维护mod意义下的个数就好了;

原文地址:https://www.cnblogs.com/dyzll/p/8850438.html