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

Code

#include <bits/stdc++.h>
using namespace std;
int n;

vector<int> a;
vector<int> b;

int main(){
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (int i=0;i<n;++i) cin >> a[i];
  for (int i=0;i<n;++i) cin >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  long long ts=0;
  for (int i=0;i<n;++i){
    ts+=abs(a[i]-b[i]);
  }
  cout << ts << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069