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

numericalstrings Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

statement.html

Problem Description

Peanut has N numerical strings, each of them containing only digits '1' to '9' and at most 5 characters long. He wishes to select K of these strings, and join them together in a certain order, to form the largest possible resultant number. What is the largest number he can form?

Input

The first line of input will contain two integers, N and K.

The next N lines of input will contain a single numerical string each.

Output

The output should contain exactly one number, the largest possible numerical string formed by concatenating K of these numerical strings together.

Limits

For all subtasks: 1 ≤ K ≤ N ≤ 100 000.

Subtask 1 (12%): All numerical strings are 1 character long.

Subtask 2 (17%): All numerical strings are of the same length.

Subtask 3 (11%): K = 1.

Subtask 4 (22%): K = N.

Subtask 5 (38%): No additional constraints.

Sample Input

5 3
5
541
33
9
98

Sample Output

9854133

Tags

Greedy, Sorting

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
112101s256MBMinimum
217201s256MBMinimum
311101s256MBMinimum
422101s256MBMinimum
538511s256MBMinimum
6011s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o numericalstrings -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.