Recapture Jerusalem

查看题解 查看答案
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb

     Saladin was a hero who resisted the Crusades.He mustered his forces to attack the strongest of the crusaders, the kingdom of Jerusalem.That day saladin surrounded the crusaders in hedian, near the west bank of lake tibalie.The Arab troops set fire to the bushes around the crusader camp, and the smoke left the crusaders breathless.The crusaders were thirsty without water.Lake tibalih was close at hand, but they could not break the Arab siege.In the heat of the summer, large Numbers of crusaders died of thirst and heat.

     The crusader general ramon led the charge, and saladin ordered his army to leave a gap for them to escape, and then to close in and encirclement all the Jerusalem infantry.In the end, the crusaders in Jerusalem were almost wiped out.After destroying the Jerusalem army, he planned to organize an elite army as the vanguard to attack Jerusalem.There are n soldiers to choose from against Saladin, and the inclusion of the ith soldier will give the troops wi combat power.But because of the complex relationship between soldiers, there are some limitations when choosing a unit. For each restriction such as x, y, v0, v1, v2. X and Y represent the ID of two soldiers. When both soldiers are selected, the army will gain additional V0 combat capability. If neither soldier is selected, the army will gain additional V1 combat capability, but selecting only one unit will deduct V2 combat capability.

     Saladin wanted to enter Jerusalem on the day of the festival to commemorate the ascent of the prophet muhammad.He wanted to know the maximum strength of the army.

输入输出格式
输入描述:
The first line contains two integers n and q, number of soldiers of value n, the number of restrictions of value q. The next line contains n integers, the ith integer being wi. The next q row, five integers in each row x, y, v0, v1, v2, represents a restriction. 1 ≤ n ≤ 1e3, 0 ≤ q ≤ 2e3, 2 ≤ wi, v0,v1,v2 ≤ 7e4, wi,v0,v1,v2 are even. The data guarantees that there will be only one constraint for any unordered pair of (x,y).
输出描述:
One line, maximum combat power output。
输入输出样例
输入样例#:
5 2
4 2 6 6 2 
4 2 4 2 2
5 1 6 6 4
输出样例#:
复制
30
提示
The sample has the highest combat power for all soldiers.
编辑器外观×
主题
字号 16px
背景
登录后免费刷此题

提交代码后在此处可查看状态