问题 L: Coin

内存限制:64 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:3

题目描述

Little F went to a party this day, and now little F wants to organize everyone to play a game together!

A total of N people participated in the game (Little F watched them play). Little F prepared N identical coins. At the beginning, each person had exactly one coin, and each person had a number ��ai indicating the upper limit of coins he could held.

There are M rounds in the game. In each round, Little F will choose two people A and B (of course, these two people are different), and then these two people have three choices:

  1. A gives B a coin
  2. B gives A a coin
  3. They do nothing

Note that at any time, the number of coins held by each person cannot exceed his holding limit ��ai.

Among the N people, there are K people who are friends of Little F, and now little F wants to know, after M rounds of games, in all possible situations, what is the maximum total number of coins held by his K friends.

输入格式

A positive integer T in the first line represents the number of test groups, for each group of test data:

The first line contains three integers N, M, K. Respectively represent the total number of people, the number of game rounds and the number of friends of Little F.

The next line contains N integers, and the i-th number ��ai represents the maximum number of coins held by the i-th person.

In the next M lines, two integers (A, B) are given in each line to indicate that the people selected in this round of the game are A and B

The next line contains K numbers �1,�2...��b1,b2...bk represents the K friends of Little F

1≤�≤10,1≤�,�,��≤3000,1≤�≤�1T10,1N,M,ai3000,1KN

输出格式

For each set of test data, the output line contains an integer, indicating the maximum total number of coins held by the K friends of Little F.

输入样例 复制

2
4 4 1
4 4 4 4
1 4
4 3
3 2
2 1
1
5 4 2
1 3 1 2 2
1 3
3 4
1 5
2 5
2 4

输出样例 复制

3
4

分类标签