Author: | М. Спорышев | Time limit: | 4 sec | |
Input file: | Standard input | Memory limit: | 512 Mb | |
Output file: | Standard output |
There is an array of integers ai. You can choose any single element and replace any single decimal digit of it with any other one. Cost of such replacement is equal to absolute value of the difference between digits.
Your program must find such a replacement of single digit in a single element that the decimal representation of the sum of all elements will contain at least one digit 9, or determine that it does not exist. The cost of chosen replacement must be minimal possible.
Leading zeroes are not eligible for replacement.
Input contains integer N — array size, followed by N integers ai.
Output three integers: element number, number of digit to be replaced and the digit to replace with.
Elements and digits are numbered starting with 0. Digits are numbered right to left.
It is guaranteed that sum of elements of the input array does not contain digit 9.
If required replacement does not exist, output −1. If there are several solutions, output any of them.
1≤N≤100000
|ai|≤109
ai≠0
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|