Problem 3019 --Milk Candy

3019: Milk Candy

"
Time Limit $5$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Calabash is now playing an RPG game on his computer. In this game, there are nnunknown numbers x1,x2,…,xnx1,x2,…,xn and mm NPCs selling hints. The ii-th NPC is selling cicihints. Each hint contains three integers lj,rj,wjlj,rj,wj, which means Calabash can pay wjwjcoins to buy this hint, and this hint can tell Calabash the value of xlj+xlj+1+⋯+xrj−1+xrjxlj+xlj+1+⋯+xrj−1+xrj

The target of the game is to figure out all the nn unknown numbers. Clever Calabash knows how to buy hints optimally, but NPCs are greedy, for the ii-th NPC, Calabash must buy exactly kiki hints from him. Note that each hint can't be bought more than once. 

This problem is much more difficult for Calabash. Please write a program to help Calabash find the cheapest way, or determine it is impossible.
The first line of the input contains an integer T(1≤T≤10)T(1≤T≤10), denoting the number of test cases. 

In each test case, there are two integers n,m(1≤n,m≤80)n,m(1≤n,m≤80) in the first line, denoting the number of unknown numbers and NPCs. 

For the next mm parts, there are two integers ci,ki(1≤ki≤ci)ci,ki(1≤ki≤ci) in the first line, denoting the number of hints the ii-th NPC has and the limit for the ii-th NPC. 

For the next cici lines, each line contains three integers lj,rj,wj(1≤lj≤rj≤n,1≤wj≤106)lj,rj,wj(1≤lj≤rj≤n,1≤wj≤106), describing each hint offered by the ii-th NPC. 

It is guaranteed that ∑ci≤80∑ci≤80 in each test case.
For each test case, print a single line containing an integer, denoting the minimum number of coins. If there is no solution, output ``-1-1'' instead.
2
2 2
1 1
1 2 1
3 2
1 1 10
2 2 100
1 2 1000
2 2
1 1
1 1 1
1 1
1 1 2
111
-1

推荐代码 查看3019 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 6 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛