Pro.ID21633 TitleReading books Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21633 AC6 Submit17 Ratio35.29% 时间&空间限制描述In the summer vacation, LRJ wants to improve himself in computer science. So he finds out N books of computer science in the school library. The books are numbered from 0 to N-1. To finish reading the i-th book, it takes LRJ time[i] minutes. But some books are similar in the content. If the i-th book and the j-th book are similar, then if LRJ has finished reading the i-th book, it will take him only 『time[j]/2』 minutes to finish reading the j-th book. Of course if LRJ has finished reading the j-th book, it will take him only 『time[i]/2』 minutes to finish reading the i-th book. Now you are asked to tell LRJ the minimal total time to finish reading all the N books. 注:『』这对符号表示"向下取整"。 输入The first line contains two integers N ( 0 ≤ N ≤ 100 ) and M ( 0 ≤ M ≤ N(N-1)/2 ). N is the total number of books. M is the number of pairs which are similar. Then the following N lines describe time[0], time[1], ..., time[N-1] ( 1 ≤ time[i] ≤ 105 ). Next comes M lines, each contains two integer (i, j), indicating that the i-th book and the j-th book are similar. Input is ended by N=0 and M=0. 输出Description In the summer vacation, LRJ wants to improve himself in computer science. So he finds out N books of computer science in the school library. The books are numbered from 0 to N-1. To finish reading the i-th book, it takes LRJ time[i] minutes. But some books are similar in the content. If the i-th book and the j-th book are similar, then if LRJ has finished reading the i-th book, it will take him only 『time[j]/2』 minutes to finish reading the j-th book. Of course if LRJ has finished reading the j-th book, it will take him only 『time[i]/2』 minutes to finish reading the i-th book. Now you are asked to tell LRJ the minimal total time to finish reading all the N books. 注:『』这对符号表示"向下取整"。 Input The first line contains two integers N ( 0 ≤ N ≤ 100 ) and M ( 0 ≤ M ≤ N(N-1)/2 ). N is the total number of books. M is the number of pairs which are similar. Then the following N lines describe time[0], time[1], ..., time[N-1] ( 1 ≤ time[i] ≤ 105 ). Next comes M lines, each contains two integer (i, j), indicating that the i-th book and the j-th book are similar. Input is ended by N=0 and M=0. Output For each test case, just output the minimal total time on a single line. Sample Input 2 1 Sample Output 11 Hint For the first test case, if LRJ read the books in the order (0, 1), then the total time = 6+10/2=11; if in the order (1, 0), then the total time = 10+6/2=13. Source 样例输入2 1 样例输出11 提示For the first test case, if LRJ read the books in the order (0, 1), then the total time = 6+10/2=11; if in the order (1, 0), then the total time = 10+6/2=13. |