## LCC/Moose '20 Contest 5 J5 - O-Mo-Te-Na-Si

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Andy is now a god at mixing and wants to make some very reactive mixtures.

He has put together an assortment of different solutions. Each has key traits he will consider. The solution has a pH of and an attractiveness of .

Andy will choose of these solutions and mix them together. The total pH is the sum of the pH's of the solutions he selects. The total attractiveness is the sum of the attractivenesses of the solutions he selects.

He defines the reactivity of a mixture as the sum of the absolute value of the total pH and the absolute value of the total attractiveness of the mixture. What is the maximum reactivity that Andy can achieve?

#### Input Specification

The first line contains two integers and .

The next lines will each contain two integers, .

#### Output Specification

Output one integer, the maximum reactivity.

##### Subtask 2 [70%]

No further constraints.

#### Sample Input 1

3 2
6 -12
5 11
-1 0

#### Sample Output 1

17

#### Sample Explanation 1

He should mix the first and third solutions. The total pH is . The total attractiveness is . The reactivity of the mixture is .

#### Sample Input 2

5 3
363756450 712662868
735867677 193944314
586260100 -192321079
95834122 802780784
418379342 -790013317

#### Sample Output 2

2904846215