#include
#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int arr1[n];
for(int i=0;i<n;i++)
{
cin>>arr1[i];
}
int arr2[n];
for(int i=0;i<n;i++)
{
cin>>arr2[i];
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
int i=0,j=n-1;
int m=INT_MIN;
long long ans;
while(i<j)
{
ans=abs(arr1[i]-arr1[j]) +abs(arr2[i]-arr2[j]) +abs(i-j);
if(ans>m)
m=ans;
i++;
j–;
}
cout<<m;
return 0;
}
Getting partial marks
Hello @Harshrajotiya have you seen the editorial video for this ?
the code in the editorial is this :
i think the logic you are using is correct…
try submitting it again.
if you still face the issue tell me here:
Happy Learning!!
still getting 50 marks
what was the error in my logic or code …
I was also thinking the way you was thinking but we were missing cases in that way.
that was the error so this is the correct code then.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.