PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#TP0000071. Biến đổi mảng: độ tăng nhỏ nhất và lớn nhất (Min-Max Array Transformation)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Biến đổi mảng: độ tăng nhỏ nhất và lớn nhất (Min-Max Array Transformation)

Min-Max Array Transformation

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Two sorted nondecreasing arrays a,ba,b are given. Nonnegative additions did_i are applied to aa, and the resulting values are sorted into bb. Find the minimum and maximum feasible did_i for each index independently.

Input

Line 1: nn. Lines 2–3: sorted arrays a,ba,b, each of length nn. Exactly one case; no TT.

Output

Print two lines of nn integers: independent minima and maxima.

Subtasks

  • Subtask 1 (20 points): Exactly one dataset; 1≤n≤91\le n\le9; 1≤ai,bi≤1091\le a_i,b_i\le10^9; both arrays nondecreasing; a feasible nonnegative increment assignment exists.
  • Subtask 2 (30 points): Exactly one dataset; 1≤n≤20001\le n\le2000; 1≤ai,bi≤1091\le a_i,b_i\le10^9; both arrays nondecreasing; a feasible nonnegative increment assignment exists.
  • Subtask 3 (50 points): Exactly one dataset; 1≤n≤2000001\le n\le200000; 1≤ai,bi≤1091\le a_i,b_i\le10^9; both arrays nondecreasing; a feasible nonnegative increment assignment exists.

Example

Input

3
2 3 5
7 11 13

Output

5 4 2
11 10 8

Explanation

The first feasible b-value for a=2,3,5 is 7,7,7. Maximum feasible increment independently uses value 13 in all three positions.