22124_ElectricPower

2022-5-16 18:21| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506129043600-Problem List-采集的数据-后羿采集器.html

Pro.ID

22124

Title

Electric Power

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22124

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Grid Computing is a hot topic these years. Many people have heard of it, but some are still confused about it. In fact, this concept came from the electric power grid. Within an electric power grid, power stations and power users are all connected to the grids. Power stations generate the electricity and input it into the grid. On the other hand, the users get electricity from the grid, unaware where it comes from. Grid Computing works in the similar way.
    Electric power grids worked very well in the past one hundred years. Recently, a plan about building a new electric power grid in our province was being discussed by GDCPC (Guangdong Construction Power Committee). This grid will cover all the cities and supply the maximum electric power. The electric network has been constructed. The committee members are now discussing where the power stations should be located. This grid has the following features:
    (1) All cities are within the network.
    (2) There is at most one power station built within a city. Of course, it locates far away from the residential area.
    (3) There is at most one connection between two cities.
    (4) There may be some circles in the network, none of which contains more than three distinct cities. For example, the network in Figure 1 is allowed while the one in Figure 2 is not.

    Figure 1                                             Figure 2
    (5) aking safety into consideration, if two cities are directly connected, they cannot both have power stations.
    (6) Due to the environment condition of the cities, the output of each power station cannot exceed a limitation value. These values differ from city to city.
    In order to provide the maximum electric power, the location of the power stations should be carefully selected. Now, it is your task to help the committee decide the cities in which power stations will be built.

    输入

    There are multiple cases.

    The input format for each case is: The first line contains only one integer N ( 1 <= N <= 100 ) indicating the number of the city. There are N positive integers (not greater than 1000) in the second line. The i-th integer is the limitation value of the i-th city. And then there’s a number in a line indicating the number of edges, i. e. , the number of pairs of linked cities. The following lines will describe the structure of the network. Each line contains two integers k and m, indicating that the k-th city and the m-th city is directly connected. N = 0 indicates the end of input.

    输出

    Description

    Grid Computing is a hot topic these years. Many people have heard of it, but some are still confused about it. In fact, this concept came from the electric power grid. Within an electric power grid, power stations and power users are all connected to the grids. Power stations generate the electricity and input it into the grid. On the other hand, the users get electricity from the grid, unaware where it comes from. Grid Computing works in the similar way.
    Electric power grids worked very well in the past one hundred years. Recently, a plan about building a new electric power grid in our province was being discussed by GDCPC (Guangdong Construction Power Committee). This grid will cover all the cities and supply the maximum electric power. The electric network has been constructed. The committee members are now discussing where the power stations should be located. This grid has the following features:
    (1) All cities are within the network.
    (2) There is at most one power station built within a city. Of course, it locates far away from the residential area.
    (3) There is at most one connection between two cities.
    (4) There may be some circles in the network, none of which contains more than three distinct cities. For example, the network in Figure 1 is allowed while the one in Figure 2 is not.

    Figure 1                                             Figure 2
    (5) aking safety into consideration, if two cities are directly connected, they cannot both have power stations.
    (6) Due to the environment condition of the cities, the output of each power station cannot exceed a limitation value. These values differ from city to city.
    In order to provide the maximum electric power, the location of the power stations should be carefully selected. Now, it is your task to help the committee decide the cities in which power stations will be built.

    Input

    There are multiple cases.

    The input format for each case is: The first line contains only one integer N ( 1 <= N <= 100 ) indicating the number of the city. There are N positive integers (not greater than 1000) in the second line. The i-th integer is the limitation value of the i-th city. And then there’s a number in a line indicating the number of edges, i. e. , the number of pairs of linked cities. The following lines will describe the structure of the network. Each line contains two integers k and m, indicating that the k-th city and the m-th city is directly connected. N = 0 indicates the end of input.

    Output
    For each case output one line containing one integer. It is the maximum electric power that the grid will provide.
    Sample Input
    2
    1 2
    1
    1 2
    5
    1 2 3 4 5
    6
    1 2
    2 3
    1 3
    3 4
    3 5
    4 5
    0
    Sample Output
    2
    7
    Source

    样例输入

    2
    1 2
    1
    1 2
    5
    1 2 3 4 5
    6
    1 2
    2 3
    1 3
    3 4
    3 5
    4 5
    0

    样例输出

    2
    7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部