Source Code
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  
  int t,n,max;
  cin >> t;
  
  for(int i=0;i<t;i++){
    cin >> n;
    int wall[n];
    int children[n];
    int dif[n];
    
     for(int i=0;i<n;i++){
      cin>>wall[i];
     }
    
     for(int i=0;i<n;i++){
      cin>>children[i];
     }
    
     max=children[0]-wall[0];
    
     for(int i=0;i<n;i++){
       if(children[i]>wall[i])
        dif[i]=abs(children[i]-wall[i]);
       else
         dif[i]=0;
    }
    
    for(int i=0;i<n;i++){
      if(max<dif[i])
        max=dif[i];
     }
      cout<<max;
 }
}
Copy
Garden Walls OmarQuishawi
GNU G++17
1 ms
192 KB
Wrong Answer