Source Code
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
#define pb push_back
ll wall_parts[200001], heights[200001];
priority_queue<ll> operations;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int t,n;
    cin >> t;
    while(t--) {
        cin >> n;
        for(int i=0; i<n; i++) {
            cin >> wall_parts[i];
        }
        for(int i=0; i<n; i++) {
            cin >> heights[i];
        }
        for(int i=0; i<n; i++) {
            if(heights[i] > wall_parts[i]) {
               operations.push(heights[i] - wall_parts[i]);
            }
        }
        cout << (operations.empty() ? 0 : operations.top()) << endl;
        while(!operations.empty()) {
            operations.pop();
        }
    }
    return 0;
}
Copy
Garden Walls osama_o
GNU G++17
56 ms
4.5 MB
Accepted