시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 2 | 0 | 0 | 0.000% |
Bogdan is a fan of riddles and puzzles. He asked his friend Anton to come up with a secret code that Bogdan would then decode.
Anton has decided to use a non-negative integer without extra leading zeroes as a secret code. The code must satisfy the following condition. If you consider any three consecutive digits of it as a three-digit integer, it is divisible by three.
Anton has given all digits of his secret code, as well as possibly some other digits, to Bodgan. He claims that the maximal number satisfying the above condition that can be created out of these digits is the secret code.
Help Bogdan to find out what is the secret code.
Input contains 10 integers: $c_0, \ldots, c_9$, here $c_i$ is the number of digits $i$ that Anton has given to Bogdan ($0 \le c_i \le 100\,000$). The sum of $c_i$ is strictly positive and doesn't exceed $100\,000$.
Output the maximal integer that can be created out of these digits. It must satisfy the condition that an integer formed by any three consecutive digits is divisible by three. It is not required to use all of the given digits. Note that any one-digit or two-digit number automatically satisfies the above condition, because it doesn't have three consecutive digits. The answer must not contain extra leading zeroes: the first digit can be $0$ only if the number is zero, in this case it must be the only digit.
1 2 3 0 0 0 0 0 0 0
21021
1 1 1 1 1 1 1 1 1 1
9876543210