VM7WC '15 #3 Silver - Test Scores

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

After landing a job in a math empire, Mr. White's first task is to grade Massey students' Putnam contests. In total, there are contests that require marking, each with a certain score associated with them. Since the contest is so difficult, it is possible for students to get negative marks.

Furthermore, Mr. White can only send in up to of the contests. Help Mr. White find the maximum sum of scores that he can send in.

Input Specification

The first line contains two space-separated integers and . This is followed by lines, each containing a single integer, describing the contest scores.

Output Specification

Print a single integer, the maximum sum of up to contest scores. The answer will be guaranteed to fit inside of a 32-bit signed integer.

Sample Input

5 2
5
2
7
5
3

Sample Output

12

• commented on Feb. 10, 2020, 2:47 p.m.

Furthermore

• commented on Jan. 24, 2020, 2:04 p.m. edited

Screw this damn question

Can't even get more than one AC

• commented on Jan. 23, 2015, 1:48 p.m.

do they scores have to be adjacent to each other, or just add the top k?

• commented on Jan. 23, 2015, 2:03 p.m.

Just going to say, you're getting something else wrong that you would probably figure out without me mentioning it but I want to sound smart.

Anyway,

"it is possible for students to get negative marks."

so as a "so-I-don't-get-banned-again" example, if BMP is really bad at computer programming and would only make his ECOO team worse if he was sent, and ECOO teams should have 4 people, and including BMP there are only 4 people who want to take ECOO, then maybe it's better to kick BMP out of the team.

• commented on Dec. 25, 2018, 10:54 p.m.

Thank you!

• commented on Jan. 23, 2015, 2:06 p.m.

he can send !!!!up-to!!!!

• commented on Jan. 22, 2015, 6:07 p.m.

can Mr. White send in no scores at all?

• commented on Jan. 22, 2015, 8:11 p.m.

Yes.

• commented on Jan. 22, 2015, 8:37 p.m.

Another question: Is it possible to post images or gifs in comments?

• commented on Jan. 23, 2015, 2:05 p.m.