National Olympiad in Informatics, China, 2005
Little H has liked computers ever since he was little. Going to high school, he has become even more obsessed with computer programs. After many years of unremitting efforts, little H has fortunately been selected into the provincial informatics competition team. He is about to go to the National Olympiad in Informatics (NOI2005) held in Zhengzhou, Henan, which he has been dreaming about day and night.
Little H's good friends little Y and little Z has received the news, and both feel very happy for him. They prepare to hold a party, inviting little H and all of his friends to attend and celebrate.
After several days of research, little Y and little Z has come up with a
list of all of little H's good friends. The list contains a total of
Little Y and little Z wish to set up a contact network for all
Clearly, not all of the friends on the list are mutually acquainted.
Even for pairs of people that are acquainted, there are varying degrees
of acquaintedness amongst different pairs. For this reason, little Y and
little Z have used their research to generate a relationship chart
between the friends, indicating which people can directly contact each
other. Furthermore for each pair of friends in contact, little Y and
little Z have also marked the contact comfort level between them.
Since 3 and 4 share a really close friendship, the comfort level between
them is recorded as 10. Since 1 and 3 are simply normal friends, the
comfort level between them is smaller. Figure 1 above depicts a network
for
Little Y and little Z wish for everybody to enjoy this party, so they've
decided to maximize the comfort level across the network: the comfort
level across the network refers to the sum of the comfort levels between
pairs of contactable friends. For example in figure 1, the bold lines
represent a network that maximizes the total comfort level, which is
However, if a person is given too many direct contacts, it is bound to be
too heavy of a burden for them. Thus, little Y and little Z has
assigned a number
Using the same example from figure 1, if we respectively assign person 1
to 5 the numbers
Can you help little Y and little Z determine the maximum total comfort level in the network, provided that all the above requirements are met?
Input Specification
There are 10 test cases party1.in
~ party10.in
that will be given to
your program (through standard input). They can be downloaded here for
you to study:
party.zip
The first line of input contains the integer party1.in
will have the single integer 1 as its first
line. The program that you submit may choose to recognize this number
(or ignore it), but must generate the output accordingly.
The second line of input contains two integers
The third line of input contains
In the following
Also, the last line of the input contains a single real number
Output Specification
The first line of output should contain a single integer, indicating the largest possible comfort level.
The following
Sample Input
0
5 6
1 1 4 2 2
1 2 5
1 3 3
2 3 6
2 5 3
3 4 10
4 5 5
0.00001
Sample Output
24
2
3
5
6
Scoring
For each test case, your score out of
- If your output is invalid, i.e.
is not within range, is repeated, the network is not connected, etc. Then your score for the test case will be . - If your output is inconsistent with the total comfort level on the first line, then your score will be
. - Otherwise, your score will be determined as follows. Let:
- If your answer is less than
, then your score will be . - If your answer is more than
, then your score will be . - Otherwise, your score will be:
- If your answer is less than
In the above,
Problem translated to English by .
Comments