Logo
(追記) (追記ここまで)

21194번 - Meditation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB29824521184.064%

문제

Luna had a stressful day and she wants to do a meditation routine that relaxes her well. Luna’s routines are more or less relaxing and to determine how relaxing a routine is, Luna computes its score: the higher the score, the more relaxing it is!

Luna has graded each of the n exercises with a positive integer and the score of a routine is simply the sum of the grades of its individual exercises. She gives you her list of graded exercises and asks you what is the maximal grade of a routine composed of k different exercises.

입력

The first line of the input contains two space-separated integers: n and k. The n following lines each contain a single integer, the i + 1-th line containing the grade gi of the i-th exercise.

출력

The output should contain a single line with a single integer: the maximal score of a routine composed of k different exercises.

제한

  • 1 ≤ k ≤ n ≤ 100 000
  • for all 1 ≤ i ≤ n, we have 0 ≤ gi ≤ 10 000

예제 입력 1

5 3
10
22
7
3
10

예제 출력 1

42

힌트

We select the exercises 1, 2 and 5 which gives a total score of 10 +たす 22 +たす 10 = 42.

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2020-2021 연습 세션 PB번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /