Task: | Differences |
Sender: | bigint bugaa |
Submission time: | 2019-05-25 11:15:46 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
Code
#include <iostream>#include <vector>#include <algorithm>using namespace std;using ll = long long;int main() {ios_base::sync_with_stdio(false);cin.tie(0);int n;cin >> n;vector<int> v1(n);vector<int> v2(n);for (int i = 0; i < n; ++i) cin >> v1[i];for (int i = 0; i < n; ++i) cin >> v2[i];sort(v1.begin(), v1.end());sort(v2.begin(), v2.end());ll res = 0;for (int i = 0; i < n; ++i) res += abs(v1[i] - v2[i]);cout << res << '\n';}