nicuvlad76

556

Oct 25th, 2020
541
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define N 1005
  3. using namespace std;
  4. ifstream fin("flici.in");
  5. ofstream fout("flici.out");
  6. int n,a[N],b[N];
  7.  
  8. int main()
  9. {
  10.     int i;
  11.     fin>>n;
  12.     for(i=1;i<=n;i++) fin>>a[i];
  13.     for(i=1;i<=n;i++) fin>>b[i];
  14.     sort(a+1,a+n+1);
  15.     sort(b+1,b+n+1);
  16.     int s=0,x;
  17.     for(i=1;i<=n;i++)
  18.     {
  19.         x=a[i]-b[i];
  20.         if(x<0)x=-x;
  21.         s+=x;
  22.     }
  23.     fout<<s;
  24. }
  25.  
RAW Paste Data