Ttangttangba Split
Time limit1sMemory limit1024 MB
Choose a line ax=by through the origin so that Junseong's share is maximized, given that Seongu takes the heavier side including treasures on the line.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Prefix sum
- Solved
- No attempts yet
Problem
Do you know how two people can split a Ssangssangba (쌍쌍바) fairly? The method goes like this.
- A splits the Ssangssangba.
- B picks one of the pieces and eats it.
- A eats the remaining pieces that B did not pick.
Junseong and Seongu find a treasure map at the same time. It shows a coordinate plane and treasures, where treasure has value . They modify the method above to split the treasures fairly.
- Junseong draws the line on the coordinate plane. ()
- Seongu picks one of the two resulting planes and takes all treasures on that plane. Treasures on the line also go to Seongu.
- Junseong takes all treasures that Seongu does not take.
Seongu always picks the plane whose treasure value sum is not smaller than the other plane's. Help the poor college student Junseong draw the line so that the sum of values Junseong takes is maximized.
Input
The first line contains an integer . ()
Each of the next lines contains , , , meaning treasure is at coordinate and has value . The values of and hold. All of , , and are integers.
Output
Print two integers and separated by a space, so that the sum of values Junseong takes is maximized. If several answers exist, print any of them.