fork download
  1. using static IO;
  2. public class IO
  3. {
  4. public static IO Cin = new();
  5. public static StreamReader reader = new(Console.OpenStandardInput());
  6. public static StreamWriter writer = new(Console.OpenStandardOutput());
  7. public static implicit operator string(IO _) => reader.ReadLine();
  8. public static implicit operator char[](IO _) => reader.ReadLine().ToArray();
  9. public static implicit operator int(IO _) => int.Parse(reader.ReadLine());
  10. public static implicit operator double(IO _) => double.Parse(reader.ReadLine());
  11. public static implicit operator string[](IO _) => reader.ReadLine().Split();
  12. public static implicit operator int[](IO _) => Array.ConvertAll(reader.ReadLine().Split(), int.Parse);
  13. public void Deconstruct(out int a, out int b) { int[] r = Cin; (a, b) = (r[0], r[1]); }
  14. public void Deconstruct(out int a, out int b, out int c) { int[] r = Cin; (a, b, c) = (r[0], r[1], r[2]); }
  15. public static void Loop(int end, Action<int> action, int start = 0, in int add = 1) { for (; start < end; start += add) action(start); }
  16. public static object? Cout { set { writer.Write(value); } }
  17. public static object? Coutln { set { writer.WriteLine(value); } }
  18. public static void Main() { Program.Coding(); writer.Flush(); }
  19. }
  20. class Program
  21. {
  22. public static void Coding()
  23. {
  24. checked
  25. {
  26. (int n, int m) = Cin;
  27. int[] source = Cin;
  28. int[] diff = new int[n + 1];
  29.  
  30. Loop(m, _ =>
  31. {
  32. (int l, int r, int add) = Cin;
  33. diff[l - 1] += add;
  34. diff[r] -= add;
  35. });
  36.  
  37. int[] result = new int[n];
  38. result[0] = diff[0];
  39. Loop(n, i => result[i] = result[i - 1] + diff[i], 1);
  40.  
  41. Cout = string.Join(' ', Enumerable.Range(0, n).Select(i => source[i] + result[i]));
  42. }
  43. }
  44. }
Success #stdin #stdout 0.06s 30872KB
stdin
10 3
1 2 3 4 5 -1 -2 -3 -4 -5
1 5 -3
6 10 5
2 7 2
stdout
-2 1 2 3 4 6 5 2 1 0