From William Lyon Mackenzie C.I.
About
not erfan
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Writer;
public class ARangeUpdateProblem {
static InputStream input = System.in;
static Writer output = new BufferedWriter(new OutputStreamWriter(System.out));
private static int readInt() throws IOException {
int cur = 0;
boolean got = false;
for (int c = 0; (c = input.read()) != -1;) {
if (c >= '0' && c <= '9') {
got = true;
cur = cur * 10 + c - '0';
} else if (got) break;
}
return cur;
}
private static long readLong() throws IOException {
long cur = 0;
boolean got = false;
for (int c = 0; (c = input.read()) != -1;) {
if (c >= '0' && c <= '9') {
got = true;
cur = cur * 10 + c - '0';
} else if (got) break;
}
return cur;
}
private static String readLine() throws IOException {
String cur = "";
boolean got = false;
for (int c = 0; (c = input.read()) != -1;) {
if (c != '\n') {
got = true;
cur += c;
}
else if (got) break;
}
return cur;
}
public static void main(String[] args) throws IOException {
int n = readInt();
int q = readInt();
long[] arr = new long[n];
long f = readLong();
long t = f;
long tt;
arr[0] = f;
for (int i = 1; i < n; i++) {
tt = readLong();
arr[i] = tt - t;
t = tt;
}
for (int i = 0; i < q; i++) {
int l = readInt();
int r = readInt();
int v = readInt();
arr[l-1] += v;
if (r != arr.length)
arr[r] -= v;
}
f = arr[0];
output.write(f + " ");
for (int i = 1; i < n; i++) {
f += arr[i];
output.write(f + " ");
}
output.close();
}
}