//#pragma GCC optimize ("-O3","unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define print(x) cout< inline void chmin(T1 & a, T2 b) { if (a > b) a = b; } template inline void chmax(T1& a, T2 b) { if (a < b) a = b; } typedef pairP; const int MOD = 1e9 + 7; const int MAX = 200060; const double pi = acos(-1); const ll INF = 1e18; int X[300010], Y[300010]; ll ans[300010]; void solve() { int N; cin >> N; REP(i, N) { cin >> X[i]; } REP(i, N)cin >> Y[i]; int ok = 0, ng = 1e9; while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; bool can = true; REP(i, N) { if (X[i] + Y[i] < mid) { can = false; break; } } if (can) { ok = mid; } else ng = mid; } print(ok); ans[0] = 0; ans[N + 1] = ok; REP(i, N) { if (Y[i] >= ok)ans[i+1] = 0; else if (X[i] >= ok)ans[i+1] = ok; else ans[i+1] = X[i]; } REP(i, N + 2) { print(ans[i]); } } signed main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }