寒假Day12:最小费用最大流问题

费用流即在网络流的基础上,给每条边都加了费用

增广路:它的最大流量取决于增广路上流量最小的边。短板效应,最大容量取决于最短木板。   

题面:

You are given N weighted open intervals. The ith interval covers (ai, bi) and weighs wi. Your task is to pick some of the intervals to maximize the total weights under the limit that no point in the real axis is covered more than k times.

Input
The first line of input is the number of test case.
The first line of each test case contains two integers, N and K (1 ≤ K ≤ N ≤ 200).
The next N line each contain three integers ai, bi, wi(1 ≤ ai < bi ≤ 100,000, 1 ≤ wi ≤ 100,000) describing the intervals.
There is a blank line before each test case.

Output
For each test case output the maximum total weights in a separate line.
View Code

数据范围:

Sample Input
4

3 1
1 2 2
2 3 4
3 4 8

3 1
1 3 2
2 3 4
3 4 8

3 1
1 100000 100000
1 2 3
100 200 300

3 2
1 100000 100000
1 150 301
100 200 300


Sample Output
14
12
100000
100301

题意:

区间k覆盖问题POJ Intervals

 

猜你喜欢

转载自www.cnblogs.com/OFSHK/p/12233599.html
今日推荐