Source Code
#include <stdio.h>

int main(){
    int t,n,count=0,x=0;
    int a[200000],b[200000];
    scanf("%d",&t);//number of test cases
    for (int test = 1;test<=t;test++){
        scanf("%d",&n);//number of wall parts and children
        int a[n],b[n];
        for(int i = 0;i<n;i++){
            scanf("%d",&a[i]);//heights of the different parts of the wall
        }
        for(int i = 0;i<n;i++){
            scanf("%d",&b[i]);//heights of each child
        }
        for(int i = 0;i<n;i++){
            if(b[i]>a[i]){
                while(b[i]>a[i]){
                    count++;
                    a[i]++;
                }
                if(count>x){
                    x=count;
                }
            }
            count =0;
        }
        printf("%d\n",x);//min number of operations
        x=0;

    }
    return 0;
}
Copy
Garden Walls LazyyTurtle
GNU GCC C11
42 ms
2.4 MB
Accepted