Buy Computers | ||||||
| ||||||
Description | ||||||
Leyni goes to a second-hand market for old computers. There are n computers at the sale and computer i costs ci Yuan. Some computers with a negative price mean that their owners will pay Leyni if he buys them. Leyni can carry at most m computers, and he won’t go to the market for a second time. Leyni wonders the maximum sum of money that he can earn. | ||||||
Input | ||||||
There are multiple test cases. The first line of input is an integer T indicating the number of test cases. Then T test cases follow. For each test case: Line 1. This line contains two space-separated integers n and m (1 ≤ m ≤ n ≤ 100) indicating the amount of computers at the sale and the amount of computers that Leyni can carry. Line 2. This line contains n space-separated integers ci (-1000 ≤ ci ≤ 1000) indicating the prices of the computers. | ||||||
Output | ||||||
For each test case: Line 1. Output the maximum sum of money that Leyni can earn. | ||||||
Sample Input | ||||||
1 5 3 -5 3 2 1 -4 | ||||||
Sample Output | ||||||
9 | ||||||
Source | ||||||
哈理工2012春季校赛 - 网络预选赛 | ||||||
Author | ||||||
齐达拉图@HRBUST 问能挣多少钱,那就是问小于m的最大负数和是多少。。大水题
|
Hust oj 1369 Buy Computers(水题)
最新推荐文章于 2021-02-27 16:50:52 发布