CSES - HIIT Open 2019 - Results
Submission details
Task:Differences
Sender:Varokaa J:tä
Submission time:2019-05-25 11:21:11 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.07 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (ll &v : a) cin >> v;
    for (ll &v : b) cin >> v;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += abs(a[i] - b[i]);
    }
    cout << res << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069