AT_abc420_c [ABC420C] Sum of Min Query
Description
You are given length- $ N $ integer sequences: $ A=(A_1,A_2,\ldots,A_N) $ and $ B=(B_1,B_2,\ldots,B_N) $ .
You are given $ Q $ queries to process in order. The $ i $ -th query $ (1\le i\le Q) $ is described as follows:
> You are given a character $ c_i $ and integers $ X_i,V_i $ . If $ c_i= $ `A`, change $ A_{X_i} $ to $ V_i $ ; if $ c_i= $ `B`, change $ B_{X_i} $ to $ V_i $ . Then, output $ \displaystyle \sum_{k=1}^N \min(A_k,B_k) $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ Q $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $ $ B_1 $ $ B_2 $ $ \ldots $ $ B_N $ $ c_1 $ $ X_1 $ $ V_1 $ $ c_2 $ $ X_2 $ $ V_2 $ $ \vdots $ $ c_Q $ $ X_Q $ $ V_Q $
Output Format
Output $ Q $ lines. The $ i $ -th line $ (1\le i\le Q) $ should contain the answer to the $ i $ -th query.
Explanation/Hint
### Sample Explanation 1
After the 1st query, $ A=(3,3,4,1),B=(2,7,1,8) $ . Therefore, output $ \displaystyle \min(3,2)+\min(3,7) + \min(4 , 1)+\min(1,8) = 7 $ on the 1st line.
After the 2nd query, $ A=(3,3,4,1),B=(2,7,3,8) $ . Therefore, output $ \displaystyle \min(3,2)+\min(3,7) + \min(4 , 3)+\min(1,8) = 9 $ on the 2nd line.
After the 3rd query, $ A=(7,3,4,1),B=(2,7,3,8) $ . Therefore, output $ \displaystyle \min(7,2)+\min(3,7) + \min(4 , 3)+\min(1,8) = 9 $ on the 3rd line.
### Constraints
- $ 1\le N,Q \le 2 \times 10^5 $
- $ 1\le A_i,B_i \le 10^9 $
- $ c_i $ is either `A` or `B`.
- $ 1\le X_i \le N $
- $ 1\le V_i \le 10^9 $
- All input values are integers.