CF1679B Stone Age Problem

题目描述

数组 $a$ 有 $n$ 个元素,需要进行 $q$ 次操作。 操作1:将第 $i$ 号元素改为 $x$ 操作2:将数组中所有元素改为 $x$ 每次操作完成后,输出当前数组中所有元素的总和。

输入格式

第一行两个整数 $n,q(1\le n,q \le2\times 10^5)$ 第二行 $n$ 个整数,表示 $a$ 中的元素 $(1\le a_i\le10^9)$ 接下来有 $q$ 行,首先输入一个整数 $t(t\in {1,2})$ 若 $t=1$,接着输入两个整数 $i,x(1\le i \le n, 1\le x \le 10^9)$ 若 $t=2$,接着输入一个整数 $x(1\le x \le 10^9)$

输出格式

共 $q$ 行,每行一个整数,表示当前数组 $a$ 中所有元素的和

说明/提示

Consider array from the example and the result of performing each query: 1. Initial array is $ [1, 2, 3, 4, 5] $ . 2. After performing the first query, array equals to $ [5, 2, 3, 4, 5] $ . The sum of all elements is $ 19 $ . 3. After performing the second query, array equals to $ [10, 10, 10, 10, 10] $ . The sum of all elements is $ 50 $ . 4. After performing the third query, array equals to $ [10, 10, 10, 10, 11 $ \]. The sum of all elements is $ 51 $ . 5. After performing the fourth query, array equals to $ [10, 10, 10, 1, 11] $ . The sum of all elements is $ 42 $ . 6. After performing the fifth query, array equals to $ [1, 1, 1, 1, 1] $ . The sum of all elements is $ 5 $ .