Source Code
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long
int main() {
    IOS
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        vector<int>w(n),ch(n);
        for(int i = 0;i<n;i++)
            cin>>w[i];
        for(int i= 0;i<n;i++)
            cin>>ch[i];
        int ans=0;
       for(int i = 0;i<n;i++)
           if(ch[i]>w[i]+ans)
               ans+=(ch[i]-(w[i]+ans));
       cout<<ans<<"\n";
    }
}
Copy
Garden Walls HusseinSaad
GNU G++17
63 ms
1.9 MB
Accepted