Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException {
- Reader fr = new Reader();
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
- int nums = fr.nextInt();
- int[] humanos = new int[200001];
- int[] skis = new int[200001];
- while (nums!= 0){
- for (int i = 0; i < nums; i++) {
- humanos[i] = fr.nextInt();
- }
- for (int i = 0; i < nums; i++) {
- skis[i] = fr.nextInt();
- }
- Arrays.sort(humanos,0,nums);
- Arrays.sort(skis,0,nums);
- long sum = 0;
- for (int i = 0; i < nums; i++) {
- sum += Math.abs(humanos[i]-skis[i]);
- }
- bw.write(sum+"\n");
- nums = fr.nextInt();
- }
- bw.flush();
- bw.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement