import java.util.Scanner; /** * @author supermejane * @date 2025/10/6 * @description BGN52 【模板】差分 */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), times = in.nextInt(); //diff[n + 1]防止越界,同时diff[n]不会被访问(作用是终止区间修改的影响),因此不会影响最终的复原 long[] a = new long[n], diff = new long[n + 1]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); diff[i] = i == 0 ? a[i] : a[i] - a[i - 1]; } while (times-- > 0) { int l = in.nextInt(), r = in.nextInt(), num = in.nextInt(); diff[l - 1] += num; diff[r] -= num; } long current = 0L; for (int i = 0; i < n; i++) { //Long current = (long) a[0]; current = i == 0 ? diff[i] : diff[i] + current; System.out.print(i == 0 ?current : " " + current); } } } //前面是模板,主要就是一开始精度有问题,但是我怕开Long数组内存不够,就用current输出,还是有精度问题(应该操作diff的时候多次相加),其实diff改成Long就行了,没想到后面开两个Long[]内存还是够。