#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; constexpr double pi=3.14159265358979; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; void solve(){ int n; cin>>n; vectorv(n+2),x(n),y(n); rep(i,n)cin>>x[i]; rep(i,n)cin>>y[i]; int minv=1e7; rep(i,n){ chmin(minv,x[i]+y[i]); } v.front()=0;v.back()=minv; for(int i=1;i<=n;++i){ if(x[i-1]>y[i-1])v[i]=max(0,minv-y[i-1]); else v[i]=min(v.back(),x[i-1]); } cout<