#BZOJ4426. Better Productivity最大生产率
Better Productivity最大生产率
题目描述
ACME Inc. is reorganizing their factory, in order to maximize their productivity of useless trinkets. The new factory design consists of p independent and identical production lines. Each production line can be assigned some number of workers.
The actual work is of course all done by machines, so the production rate of a production line is independent of the actual number of workers assigned to it. However, the workers work in shifts, and due to local safety regulations, a production line can only be active while all of its workers are present (any worker who arrives before the last person to arrive, or leaves after the first person leaves, will be spending the inactive time having a coffee break). In other words, the productivity of a production line equals the length of the timespan during which all of the workers assigned to this production line are present. Crucially, the productivity of each line must be positive (i.e., the last worker to arrive for a line must arrive strictly before the first worker for that line leaves), since otherwise the workers feel that their jobs are meaningless.
Unfortunately, due to some pesky labor laws, ACME are not allowed to fire any of their workers, which means that each of their n workers must be assigned to some production line, even though this may actually decrease the overall productivity of the factory.
All these rules and regulations are making a headache for ACME management. Can you help them figure out the maximum possible total productivity (sum of productivities of the p production lines) of their new factory?
ACME公司正在重组他们的工厂,以最大化他们生产无用的小饰品的效率。新工厂由相同的p个独立生产线组成。每一条生产线都可以被分配一些员工。
实际的工作都是由机器完成,所以一条生产线的效率是由分配给它的员工数量决定的。但是,员工们轮班工作,而且由于当地安全法规定,一条生产线只有在被分配给它的员工都正在工作岗位上时,才能开启(任何比最后到的员工先到或比最先离开的员工后离开的员工,会用时间来喝咖啡休息)。换句话说,生产线的生产效率等于它的所有员工都在岗位上的时间长度。最重要的是,生产线的生产效率必须为正数(即最晚到达的员工到达的时间必须严格早于最早离开的员工离开的时间),否则工人们会认为他们的工作没有意义。
不幸的是,由于讨厌的劳动法,ACME不能解雇他们的员工,这就意味着,他们的n个员工每一个都要分配到某一个生产线,即使这会降低工厂的生产率。
这些规定正使ACME的高层们头疼,你能帮他们弄清他们的新工厂的最大生产率(p个生产线生产率总和)吗?
输入格式
The input consists of:
• one line containing two integers n and p (1≤p≤n≤2001≤p≤n≤200), the number of employees and the number of production lines;
• n lines each containing two integers a and b(0≤a<b≤1000000≤a<b≤100000), representing a worker that arrives at time a and leaves at time b.
You may assume that there exists at least one valid assignment of workers to production lines.
输入包括:
第一行包括两个整数n和p(1<=p<=n<=200),n是员工数量,p是生产线数量。
接下来n行每行包括两个整数a和b(0<=a<b<=100000),描述了一个员工在a时刻到达,b时刻离开。
你可以认为至少存在一个有效解。
输出格式
Output the maximum productivity level possible for the factory.
输出这个工厂可能的最大生产率。
4 2 1 3 1 5 4 6 2 7
4