CSES - HIIT Open 2019 - Results
Submission details
Task:Differences
Sender:bigint bugaa
Submission time:2019-05-25 11:15:46 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.06 sdetails

Code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	vector<int> v1(n);
	vector<int> v2(n);
	for (int i = 0; i < n; ++i) cin >> v1[i];
	for (int i = 0; i < n; ++i) cin >> v2[i];
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	ll res = 0;
	for (int i = 0; i < n; ++i) res += abs(v1[i] - v2[i]);
	cout << res << '\n';
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069