Task: | Differences |
Sender: | Game of Nolife |
Submission time: | 2019-05-25 11:18:25 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.07 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second #define X real() #define Y imag() using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; vector<int> a(n); vector<int> b(n); for (int i=0;i<n;i++){ cin>>a[i]; } for (int i=0;i<n;i++){ cin>>b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); ll s=0; for (int i=0;i<n;i++){ s+=(ll)llabs(a[i]-b[i]); } cout<<s<<endl; }