301846: CF349B. Color the Fence

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Color the Fence

题意翻译

$Igor$深深爱上了$Tanya$. 现在, $Igor$想表达他的爱意, 他便在$Tanya$家对面的墙上写下一串数字. $Igor$认为, 数字写得越大, $Tanya$越喜欢他. 不幸的是, 他只有$v$升油漆, 每个数字都会花掉一定的油漆$a_i$. $Igor$不喜欢$0$ 所以数中不会出现$0$. 问$Igor$能得到的最大的数是多少.

题目描述

Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. Unfortunately, Igor could only get $ v $ liters of paint. He did the math and concluded that digit $ d $ requires $ a_{d} $ liters of paint. Besides, Igor heard that Tanya doesn't like zeroes. That's why Igor won't use them in his number. Help Igor find the maximum number he can write on the fence.

输入输出格式

输入格式


The first line contains a positive integer $ v $ $ (0<=v<=10^{6}) $ . The second line contains nine positive integers $ a_{1},a_{2},...,a_{9} $ $ (1<=a_{i}<=10^{5}) $ .

输出格式


Print the maximum number Igor can write on the fence. If he has too little paint for any digit (so, he cannot write anything), print -1.

输入输出样例

输入样例 #1

5
5 4 3 2 1 2 3 4 5

输出样例 #1

55555

输入样例 #2

2
9 11 1 12 5 8 9 10 6

输出样例 #2

33

输入样例 #3

0
1 1 1 1 1 1 1 1 1

输出样例 #3

-1

Input

题意翻译

$Igor$深深爱上了$Tanya$. 现在, $Igor$想表达他的爱意, 他便在$Tanya$家对面的墙上写下一串数字. $Igor$认为, 数字写得越大, $Tanya$越喜欢他. 不幸的是, 他只有$v$升油漆, 每个数字都会花掉一定的油漆$a_i$. $Igor$不喜欢$0$ 所以数中不会出现$0$. 问$Igor$能得到的最大的数是多少.

加入题单

上一题 下一题 算法标签: