Multiple Choice Test
Time limit1sMemory limit1024 MB
Pick one vector from each of N groups so the squared distance of the total sum from the origin is maximized.
- Level
Hard8 of 10
- Topics
- Geometry, Greedy, Implementation, Math
- Solved
- No attempts yet
Problem
The cows are taking a multiple choice test. But instead of a standard test where your selected choices are scored for each question individually and then summed, in this test your selected choices are summed before being scored.
Specifically, you are given () groups of integer vectors on the 2D plane, where each vector is denoted by an ordered pair . Choose one vector from each group such that the sum of the vectors is as far away from the origin as possible.
It is guaranteed that the total number of vectors is at most . Each group has size at least , and within a group, all vectors are distinct. It is also guaranteed that every and coordinate has absolute value at most .
Input
The first line contains , the number of groups.
Each group starts with , the number of vectors in the group, followed by lines containing the vectors in that group. Consecutive groups are separated by newlines.
Output
The maximum possible squared Euclidean distance.
Hint
It is optimal to select from the first group, from the second group, and from the third group. The sum of these vectors is , which is squared distance from the origin.