{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAs Dr. Orooji is getting older, he is becoming more attached to older items and has difficultyletting go of them (he claims they have historical value). For example, he still has the first tablehe got for the programming team! The situation is the same at home, e.g., there is a broken TVremote control but Dr. O still uses it, because he considers it an old item with historical value!\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eThe Problem:\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe old remote control has 12 buttons: digits 0-9, channel down, and channel up. There are noother buttons on the remote control. Some digits on the remote don’t work but channel up/downalways works. So, to get to a particular channel, Dr. O sometimes has to use the channel up/down.For example, let’s assume digits 0 and 5 on the remote don’t work:\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eIf Dr. O wants to watch channel 102, he would select 99 and then “channel up” 3 times.\u003c/p\u003e\n\u003cp\u003eIf he wants to watch channel 597, he would select 611 and then “channel down” 14 times.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c/p\u003e\n\u003cp\u003eGiven the digits that do not work and a target channel, determine how many times Dr. O needs to hit channel up or down. Dr. O, of course, wants to exert the least energy, hence he wants to hit the channel up/down the minimum number of times.\u0026nbsp; Assume that Dr. O will enter a channel between 0 and 999 (inclusive) to start and that channel down has no effect at 0 and channel up has no effect at 999.\u0026nbsp;\u0026nbsp;\u003cbr\u003e\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eThe Input:\u0026nbsp;\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe first input line contains an integer, n (1 ≤ n ≤ 9), indicating how many digits on the remote donot work. These broken digits are listed (in increasing order) on the same input line. The secondinput line provides the target channel (an integer between 1 and 999, inclusive).\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u003cb\u003eThe Output:\u0026nbsp;\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe output consists of a single integer, indicating how many times Dr. O needs to hit channelup/down. Note that, since one or more digits work, it is always possible to reach the target channel.\u0026nbsp;\u003cbr\u003e\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 0 8 9\n35\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 1 2 5 9\n250\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e50\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}}]}