{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) \u0026gt;\u003d 0 of power, may produce an amount 0 \u0026lt;\u003d p(u) \u0026lt;\u003d p\n \u003csub\u003emax\u003c/sub\u003e(u) of power, may consume an amount 0 \u0026lt;\u003d c(u) \u0026lt;\u003d min(s(u),c\n \u003csub\u003emax\u003c/sub\u003e(u)) of power, and may deliver an amount d(u)\u003ds(u)+p(u)-c(u) of power. The following restrictions apply: c(u)\u003d0 for any power station, p(u)\u003d0 for any consumer, and p(u)\u003dc(u)\u003d0 for any dispatcher. There is at most one power transport line (u,v) from a node u to a node v in the net; it transports an amount 0 \u0026lt;\u003d l(u,v) \u0026lt;\u003d l\n \u003csub\u003emax\u003c/sub\u003e(u,v) of power delivered by u to v. Let Con\u003dΣ\n \u003csub\u003eu\u003c/sub\u003ec(u) be the power consumed in the net. The problem is to compute the maximum value of Con. \n \u003cbr\u003e\n \u003ccenter\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/1c1354d5a7c820146d570a7875b230b3?v\u003d1526602141\" SRC\u003d\"CDN_BASE_URL/1c1354d5a7c820146d570a7875b230b3?v\u003d1526602141\"\u003e\n \u003c/center\u003e \n \u003cbr\u003eAn example is in figure 1. The label x/y of power station u shows that p(u)\u003dx and p\n \u003csub\u003emax\u003c/sub\u003e(u)\u003dy. The label x/y of consumer u shows that c(u)\u003dx and c\n \u003csub\u003emax\u003c/sub\u003e(u)\u003dy. The label x/y of power transport line (u,v) shows that l(u,v)\u003dx and l\n \u003csub\u003emax\u003c/sub\u003e(u,v)\u003dy. The power consumed is Con\u003d6. Notice that there are other possible states of the network but the value of Con cannot exceed 6. \n \u003cbr\u003e\n \u003c/div\u003e\u003cbr\u003e\n有三种结点,第一种是发电站,它能不会消耗电能;一种是用户,他不会产生电能;再有一种就是一个我 变电站(?),它既不会产生电也不会消耗电。每个点都有两个属性,产生电量,消耗电量;现在问你最多这个网络能消耗多少的电量。"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n There are several data sets in the input. Each data set encodes a power network. It starts with four integers: 0 \u0026lt;\u003d n \u0026lt;\u003d 100 (nodes), 0 \u0026lt;\u003d np \u0026lt;\u003d n (power stations), 0 \u0026lt;\u003d nc \u0026lt;\u003d n (consumers), and 0 \u0026lt;\u003d m \u0026lt;\u003d n^2 (power transport lines). Follow m data triplets (u,v)z, where u and v are node identifiers (starting from 0) and 0 \u0026lt;\u003d z \u0026lt;\u003d 1000 is the value of l\n \u003csub\u003emax\u003c/sub\u003e(u,v). Follow np doublets (u)z, where u is the identifier of a power station and 0 \u0026lt;\u003d z \u0026lt;\u003d 10000 is the value of p\n \u003csub\u003emax\u003c/sub\u003e(u). The data set ends with nc doublets (u)z, where u is the identifier of a consumer and 0 \u0026lt;\u003d z \u0026lt;\u003d 10000 is the value of c\n \u003csub\u003emax\u003c/sub\u003e(u). All input numbers are integers. Except the (u,v)z triplets and the (u)z doublets, which do not contain white spaces, white spaces can occur freely in input. Input data terminate with an end of file and are correct.\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n For each data set from the input, the program prints on the standard output the maximum amount of power that can be consumed in the corresponding network. Each result has an integral value and is printed from the beginning of a separate line.\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2 1 1 2 (0,1)20 (1,0)10 (0)15 (1)20\n7 2 3 13 (0,0)1 (0,1)2 (0,2)5 (1,0)1 (1,2)8 (2,3)1 (2,4)7\n (3,5)2 (3,6)5 (4,2)7 (4,3)5 (4,5)1 (6,0)5\n (0)5 (1)2 (3)2 (4)1 (5)4\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e15\n6\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The sample input contains two data sets. The first data set encodes a network with 2 nodes, power station 0 with pmax(0)\u003d15 and consumer 1 with cmax(1)\u003d20, and 2 power transport lines with lmax(0,1)\u003d20 and lmax(1,0)\u003d10. The maximum value of Con is 15. The second data set encodes the network from figure 1.\n \u003c/div\u003e"}}]}