Amplitude Hackathon Winter '24 Problem 5 - WhenTaken (Year)

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 0.25s
Memory limit: 1G

Problem type

Eric has been challenged by his friends to yet another round of WhenTaken, the popular game where players guess when and where a picture was taken.

The Amplitude group has gotten so good at WhenTaken that they always get the location correct, so now they are refining their ability to guess the year that a picture was taken. Pictures can taken in any year from 1 to 2024, and guesses can be any integer from 1 to 2024. If a picture was taken in year a and the group guesses that it was taken in year b, then the group gets (a-b)^2 penalty points.

Eric remembers every year that was guessed as well as the year of every picture in the last round of WhenTaken, but he does not remember which guess was for which picture. He wants to know the minimum and maximum number of penalty points that the group could have gotten.

Constraints

1 \le n \le 50

Input Specification

The first line of input contains a single integer, n.

The second line of input contains n integers, the years of the pictures in the last round.

The third line of input contains n integers, the guesses made by the group.

Output Specification

Output two integers, the minimum possible number of penalty points and the maximum possible number of penalty points.

Sample Input 1

2
1 2
1 2

Sample Output 1

0 2

Sample Explanation 1

If both guesses were correct, then the group got 0 penalty points. However, if both guesses were incorrect, then the group got 2 penalty points.

Sample Input 2

3
31 41 59
27 18 28

Sample Output 2

1326 1886

Sample Explanation 2

The minimum penalty point count is obtained with (41-27)^2 + (31-18)^2 + (59-28)^2 = 1326. The maximum penalty point count is obtained with (41-27)^2 + (59-18)^2 + (31-28)^2 = 1886.


Comments

There are no comments at the moment.