oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

potatosalad Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

potatosalad.html

Problem Description

Jiahai is making a potato salad today! In fact, just for this purpose, he is harvesting potatoes from his very own potato farm today. Being incredibly adept at picking potatoes, he has managed to pick up N potatoes from the potato farm.

However, his culinary competition is coming up in D days! This culinary competition involves making as much mashed potato as possible. However, he can only process one potato a day. He has a set of N potatoes from the potato farm, each with a different mass. A potato with mass M kg can be made into M kg of mashed potato.

Given the set of potatoes that he has collected and their respective masses, calculate the maximum amount of mashed potato (in kg) he can make at the end of D days.

PS: This is based on a true story. In fact, here is a poster of JPF in real life:

Input

The first line of input will contain two integers, N and D.
The second line of input will contain N integers, with the ith integer representing the mass of the ith potato.

Output

Your output should contain one integer, the maximum amount of mashed potato he can make.

Limits

1 <= N <= 100 000
1 <= Mi <= 1 000

Sample Input 1

4 2
9 1 4 12

Sample Output 1

21

jpf.png

Tags

Greedy, Sorting

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100101s64MBMinimum
2011s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o potatosalad -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.