#B. 火柴棒拼数

    Type: Default 1000ms 256MiB

火柴棒拼数

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

初一竞赛组期末考题2

Description

nn根火柴,mm种数字,数字1,2,3,4,5,6,7,8,91,2,3,4,5,6,7,8,9分别需要2,5,5,4,5,6,3,7,62,5,5,4,5,6,3,7,6根火柴,要求nn根火柴全部都用完且拼成的数字最大,输出这个数字。

Format

Input

第一行两个正整数nnmm,第二行mm个正整数表示可用的数字。

Output

一行,表示能拼出的最大数字。注意数字的位数可能超过6464位。

Samples

20 4
3 7 8 4
777773
101 9
9 8 7 6 5 4 3 2 1
71111111111111111111111111111111111111111111111111

Limitation

对20%的数据,n≤100。

对40%的数据,n≤2000。

对100%的数据,2≤n≤10000,1≤m≤9。

1s, 1024KiB for each test case.

2023-2024第二学期初一信息竞赛组期末考

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2024-6-24 10:45
End at
2024-6-24 16:03
Duration
1.5 hour(s)
Host
Partic.
41