CSES - HIIT Open 2019 - Results
Submission details
Task:Differences
Sender:tykkipeli
Submission time:2019-05-25 11:47:28 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.14 sdetails

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;
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069