CSES - HIIT Open 2019 - Results
Submission details
Task:Differences
Sender:.*
Submission time:2019-05-25 13:27:25 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.08 sdetails

Code

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define M 1000000007
#define N (1<<18)
#define P complex<long long>
#define X real()
#define Y imag()
using namespace std;
int n, f;
ll ans;
vector<int> v, vv;
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin >> n;
for(int i=0; i<n; i++) {
cin >> f;
v.push_back(f);
}
for(int i=0; i<n; i++) {
cin >> f;
vv.push_back(f);
}
sort(v.begin(), v.end());
sort(vv.begin(), vv.end());
for(int i=0; i<n; i++)
ans += abs(v[i]-vv[i]);
cout << ans;
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069