Task: | Differences |
Sender: | Barely div 1 |
Submission time: | 2019-05-25 11:10:38 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.13 s | details |
Code
#include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<int> a; vector<int> b; for (int i = 0; i < n; i++) { int num; cin>>num; a.emplace_back(num); } for (int i = 0; i < n; i++) { int num; cin>>num; b.emplace_back(num); } sort(a.begin(), a.end()); sort(b.begin(), b.end()); long long tot = 0; for (int i =0; i<n;i++) { tot += a[i] > b[i] ? a[i]-b[i] : b[i]-a[i]; } cout << tot; }