zoukankan      html  css  js  c++  java
  • SZU:B36 Reading books

    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 \left \lfloor \frac{time[j]}{2} \right \rfloor minutes to finish reading the j-th book. Of course if LRJ has finished reading the j-th book, it will take him only \left \lfloor \frac{time[i]}{2} \right \rfloor 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\leq N \leq 100) and M(0\leq M \leq N\times (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],\cdots,time[n-1](1\leq time[i] \leq 10^{5}).

    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 with EOF.

    Output

    For each test case, just output the minimal total time on a single line.

    Sample Input

    2 1
    6
    10
    0 1
    3 2
    1
    2
    3
    0 1
    1 2
    3 1
    2
    4
    6
    0 1
    

    Sample Output

    11
    3
    10
    

     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.

  • 相关阅读:
    Linux下修改时间时区的方法介绍
    IIS启用GZip压缩的详细教程(图文)
    jquery定时器的简单代码
    IIS启用GZIP压缩js、css无效的原因及解决方法
    python批量导出导入MySQL用户的方法
    mysql执行计划介绍
    js+json用表格实现简单网站左侧导航
    React Native 二维码扫描组件
    mysql如何修改开启允许远程连接
    react native中的聊天气泡以及timer封装成的发送验证码倒计时
  • 原文地址:https://www.cnblogs.com/firstrate/p/3080649.html
Copyright © 2011-2022 走看看