#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long int ll const MOD = 1000000007; ll const INF = (long long int)1 << 61; ll mypow(ll x,ll n,ll mod = MOD){ ll ret = 1; while(n > 0){ if(n&1){ ret = (ret*x)%mod; } x = (x*x)%mod; n >>= 1; } return ret; } ll mygcd(ll a,ll b){ if(b == 0)return a; return mygcd(b,a%b); } ll twoPow(ll shiftNum){ return (1LL << (shiftNum - 1)); } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector x(n),y(n); for(int i = 0; i < n; i++){ cin >> x[i]; } for(int i = 0; i < n; i++){ cin >> y[i]; } ll ok = 0; ll ng = 10000000; while(abs(ok - ng) > 1){ ll middle = (ok+ng)/2; bool flag = true; for(int i = 0; i < n; i++){ if(x[i] + y[i] < middle){ flag = false; } } if(flag){ ok = middle; }else{ ng = middle; } } vector ans(n); for(int i = 0; i < n; i++){ if(x[i] > ok){ ans[i] = ok; }else{ ans[i] = x[i]; } } cout << ok << endl; cout << 0 << endl; for(int i = 0; i< n; i++){ cout << ans[i] << endl; } cout << ok << endl; return 0; }