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. int n = Cin;
  25. int[] candys = new int[n];
  26. Loop(n, i => candys[i] = Cin);
  27. LinearExpression expr = new(1, 0);
  28. Loop(n, i => expr = -expr + candys[i]);
  29. int x = expr.Constant / 2;
  30. Coutln = x;
  31. Loop(n-1, i => Coutln = x = candys[i] - x, 0);
  32. }
  33. }
  34. public struct LinearExpression {
  35. public LinearExpression(int coefficient, int constant)
  36. {
  37. this.Coefficient = coefficient;
  38. this.Constant = constant;
  39. }
  40. public int Coefficient, Constant;
  41. public static LinearExpression operator +(LinearExpression a, int b) => new(a.Coefficient, a.Constant + b);
  42. public static LinearExpression operator -(LinearExpression a, LinearExpression b) => new(a.Coefficient - b.Coefficient, a.Constant - b.Constant);
  43. public static LinearExpression operator -(LinearExpression a) => new(-a.Coefficient,-a.Constant);
  44. }
Success #stdin #stdout 0.05s 30072KB
stdin
3
5
7
6
stdout
2
3
4