Dungeon

Provide arrays a, b, c. Then repeatedly pick from a and b to perform moves according to the rules.

Constraints: a and b — length 1..20, values 1..1,000,000,000. c — length = length(b), values 0..1,000,000,000.
Examples:
  • Example 1: a = 2 2 2, b = 2 3, c = 3 2
  • Example 2: a = 2 3, b = 2 3 4, c = 0 0 0
  • Example 3: a = 1 7 7, b = 6 6 2 2 2, c = 2 0 0 7 2
  • Example 4: a = 1 5 3 5, b = 7 4 6 5, c = 0 0 1 6
  • Example 5: a = 1 1000000000, b = 1000000000 1, c = 1000000000 0