wattanapong suttapak SE, ICT University of Phayao
Sample Input ACM International Collegiate Programming Contest (abbreviated as ACM-ICPC or just ICPC) is an annual multi-tiered computer programming competition among the universities of the world. The contest is sponsored by IBM. Headquartered at Baylor University, with autonomous regions on six continents, the ICPC is directed by Baylor Professor William B. Poucher, Executive Director, and operates under the auspices of the Association for Computing Machinery (ACM). The 2012 ACM-ICPC Asia Hatyai Regional Programming Contest is held during November It is hosted by Prince of Songkla University, Hatyai campus. E-N-D Sample Output international
Solution 1. Scan แบบ next(); 2. trim string 3. check character ทีละตัวว่าเป็น isdigit หรือ “_” หรือไม่ 4. เปรียบเทียบ String ไหนยาวสุด แสดงค่า String นั้น
8 : 44 9 : 88 = : 70 = : : 68 = : : 60 = 7 15 : : : 56 = 3 18 : 6 19 : : : : 96 = : 86 = : 66 = : : : 104 = : 102 = : 98 = : 90 = : 74 = : : 84 = : 62 = 9 35 : : : 72 = : : 76 = : : 92 = : 78 = : : 100 = : 94 = : 82 = : 58 = 5 48 : : : : 80 = : : 1 54 : 2 55 : 4 56 : 8 57 : 16
0 : 1 1 : 3 2 : 9 3 : 27 4 : 81 = 28 5 : 243 = 31 6 : 729 = 40 7 : 14 8 : 42 9 : : 7 11 : : : : : 5 16 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 44 : : : 4 47 : : : 2 50 : 6 51 : : 1 53 : 3 54 : 9 55 : 27 y : x
8 : 44 9 : 88 = : 70 = : : 68 = : : 60 = 7 15 : : : 56 = 3 18 : 6 19 : : : : 96 = : 86 = : 66 = : : : 104 = : 102 = : 98 = : 90 = : 74 = : : 84 = : 62 = 9 35 : : : 72 = : : 76 = : : 92 = : 78 = : : 100 = : 94 = : 82 = : 58 = 5 48 : : : : 80 = : : 1 54 : 2 55 : 4 56 : 8 57 : 16
0 : 1 1 : 3 2 : 9 3 : 27 4 : 81 = 28 5 : 243 = 31 6 : 729 = 40 7 : 14 8 : 42 9 : : 7 11 : : : : : 5 16 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 44 : : : 4 47 : : : 2 50 : 6 51 : : 1 53 : 3 54 : 9 55 : 27
0 : 1 1 : 4 2 : 16 3 : 11 4 : 44 5 : 17 6 : 15 7 : 7 8 : 28 9 : 6 10 : : : : : : : : 9 18 : : : : : : : : : 1 27 : 4 28 : : : : : : 7 34 : : 6 36 : : : : : : : : 9 44 : : : : : : : : : 1 53 : 4 54 : : 11 คิดย้อนกลับ 5 : : : 41 ans. 41
Assume that the world is coming to its end. Mr. A and his family are among the very few people who stay alive. He is driving a car along the road in Bangkok center finding his way to get out of the city as soon as possible. However, the fuel is limited and most of the gas stations have just been wiped out by the earthquake. At this point, it becomes clear that the problem is how to select the best way to drive. Given that now Mr. A reaches the big junction with N ways to go. With the help of the GPS, which surprisingly can still function, the information about each way is provided in the form of the number of milestones and the amount of fuel to reach them. At this point Mr. A wants to go to any one of the N ways. Additionally, he wants to reach the last milestone in that chosen way. However, this information seems to be useless to Mr. A, now that he is in panic and temporarily loses an ability of calculations. Your task is to write the program to calculate a way that Mr. A should take with the minimum use of fuel. If there are two or more ways that consume the same amount of fuel, the program will always select the first one in the input file.
Input: The first line of the input is the number of test cases. This is followed by the input of each case one by one. For each case, the first line indicates an amount of gasoline in your car, K (K < 50). The second line shows the number of ways to go (N, N < 10). Then the information about each way out of all N ways is input. The information about each way contains M+1 lines where M (0 < M < 1000) is the number of milestones in that such way. The first line indicates M, followed by an amount of fuel required to reach each milestone. Note that the amount of fuels required to reach any milestone is an integer and calculated from the current car position. Each test case is ended with character E. Output: The output of each test case is shown respectively. For each case, the first line shows the index number of the way Mr. A should take and the second line shows a total amount of fuel for driving in such way. The third line states the result if Mr. A will finally reaches the destination. The “Y” means yes and “N” means no.
inputoutput