Report Card
InterviewTime limit1sMemory limit256 MB
Given N (x, y) points, find positive integers a and b up to 100 that minimize the sum of squared residuals of f(x) = ax + b.
- Level
Easy3 of 10
- Topics
- Brute force, Math, Implementation
- Solved
- No attempts yet
Problem
Dongha failed another course this semester and landed on academic probation again. To stay off the list next time, he decided to study.
Dongha wondered how much study time turns into how many points, so he surveyed students. Student studied for hours and scored points.
From this data he wants to estimate the exam score after hours of study as . Find and for him.

A function that predicts an exam score from study time should keep the gap between and small on every record .
RSS (residual sum of squares) turns that idea into a formula. The smaller the RSS, the better the model fits the data.
Among the positive integers and that are at most 100, find the pair that minimizes RSS. The intermediate values grow large, so watch out for overflow.
Input
The first line contains the number of records . ()
Each of lines 2 through contains the study time and the exam score of student , in that order. (, and and are integers)
Output
Print and that minimize RSS on one line, separated by a space.
No input has more than one pair reaching the minimum RSS.