Task: | Differences |
Sender: | O(n^10) |
Submission time: | 2019-05-25 11:28:31 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.07 s | details |
Code
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<long long> a; vector<long long> b; for(int i = 0; i < n; i++) { long long bb; cin >> bb; a.push_back(bb); } for(int i = 0; i < n; i++) { long long bb; cin >> bb; b.push_back(bb); } sort(b.begin(), b.end()); long long kys = 0; sort(a.begin(), a.end()); for(int i = 0; i < n; i++) { kys += abs(a[i]-b[i]); } cout << kys << "\n"; }