Task: | Differences |
Sender: | tykkipeli |
Submission time: | 2019-05-25 11:47:28 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.14 s | details |
Code
#include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[1010101];ll b[1010101];int main() {int n;cin >> n;for (int i = 0; i < n; i++) {cin >> a[i];}for (int i = 0; i < n; i++) {cin >> b[i];}sort(a,a+n);sort(b,b+n);ll ans = 0;for (int i = 0; i < n; i++) {ans += abs(a[i]-b[i]);}cout << ans << endl;}