PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000033. Số ghép lớn nhất (Largest Number)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số ghép lớn nhất (Largest Number)
Largest Number
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given non-negative integers, arrange them and concatenate their decimal representations to form the largest possible number.
Input
The first line contains . The second line contains integers.
Output
Print the largest number as a string. If all values are zero, print a single 0.
Constraints
- .
- for .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
5
3 30 34 5 9
Output
9534330
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.