CSES - HIIT Open 2019 - Results
Submission details
Task:Differences
Sender:O(n^10)
Submission time:2019-05-25 11:28:31 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.07 sdetails

Code

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

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a;
  vector<long long> b;
  for(int i = 0; i < n; i++) {
    long long bb; cin >> bb;
    a.push_back(bb);
  }
  for(int i = 0; i < n; i++) {
    long long bb; cin >> bb;
    b.push_back(bb);
  }
  sort(b.begin(), b.end());
  long long kys = 0;
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    kys += abs(a[i]-b[i]);
  }
  cout << kys << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
100000
880024238 421943433 201872615 ...

correct output
79489641069

user output
79489641069