308016: CF1452E. Two Editorials

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Two Editorials

题意翻译

【题目描述】 ICPC 刚刚结束,某校 $m$ 名参赛选手,从 $1$ 到 $m$ 编号,要回去补文化课了。文化课有 $1...n$ 共 $n$ 个知识点。学校安排了两个教师,他们每个人要告诉学生他们要上的 $k$ 个连续的知识点。教师独立选择 $k$ 个连续知识点。两个教师选择的知识点可以重合、相交或根本不相交。第 $i$ 个学生只对 $l_i...r_i$ 的知识点有兴趣。每个学生总是选择只听教师教授的知识点中他感兴趣的最大数量的知识点,令知识这个最大数为 $a_i$。需要注意的是,两个教师是同时开课的,即没有学生可以听两个教师的课,即使他们的知识点没有交叉。两个教师希望自己选择 $k$ 个连续的知识点,使得所有学生的 $a_i$ 之和最大。 【输入】 第一行三个正整数 $n$,$m$,$k$。 接下来 $m$ 行,每行两个正整数 $l_i$,$r_i$。 【输出】 输出 $a_i$ 之和的最大值

题目描述

Berland regional ICPC contest has just ended. There were $ m $ participants numbered from $ 1 $ to $ m $ , who competed on a problemset of $ n $ problems numbered from $ 1 $ to $ n $ . Now the editorial is about to take place. There are two problem authors, each of them is going to tell the tutorial to exactly $ k $ consecutive tasks of the problemset. The authors choose the segment of $ k $ consecutive tasks for themselves independently of each other. The segments can coincide, intersect or not intersect at all. The $ i $ -th participant is interested in listening to the tutorial of all consecutive tasks from $ l_i $ to $ r_i $ . Each participant always chooses to listen to only the problem author that tells the tutorials to the maximum number of tasks he is interested in. Let this maximum number be $ a_i $ . No participant can listen to both of the authors, even if their segments don't intersect. The authors want to choose the segments of $ k $ consecutive tasks for themselves in such a way that the sum of $ a_i $ over all participants is maximized.

输入输出格式

输入格式


The first line contains three integers $ n, m $ and $ k $ ( $ 1 \le n, m \le 2000 $ , $ 1 \le k \le n $ ) — the number of problems, the number of participants and the length of the segment of tasks each of the problem authors plans to tell the tutorial to. The $ i $ -th of the next $ m $ lines contains two integers $ l_i $ and $ r_i $ ( $ 1 \le l_i \le r_i \le n $ ) — the segment of tasks the $ i $ -th participant is interested in listening to the tutorial to.

输出格式


Print a single integer — the maximum sum of $ a_i $ over all participants.

输入输出样例

输入样例 #1

10 5 3
1 3
2 4
6 9
6 9
1 8

输出样例 #1

14

输入样例 #2

10 3 3
2 4
4 6
3 5

输出样例 #2

8

输入样例 #3

4 4 1
3 3
1 1
2 2
4 4

输出样例 #3

2

输入样例 #4

5 4 5
1 2
2 3
3 4
4 5

输出样例 #4

8

说明

In the first example the first author can tell the tutorial to problems from $ 1 $ to $ 3 $ and the second one — from $ 6 $ to $ 8 $ . That way the sequence of $ a_i $ will be $ [3, 2, 3, 3, 3] $ . Notice that the last participant can't listen to both author, he only chooses the one that tells the maximum number of problems he's interested in. In the second example the first one can tell problems $ 2 $ to $ 4 $ , the second one — $ 4 $ to $ 6 $ . In the third example the first one can tell problems $ 1 $ to $ 1 $ , the second one — $ 2 $ to $ 2 $ . Or $ 4 $ to $ 4 $ and $ 3 $ to $ 3 $ . Every pair of different problems will get the same sum of $ 2 $ . In the fourth example the first one can tell problems $ 1 $ to $ 5 $ , the second one — $ 1 $ to $ 5 $ as well.

Input

题意翻译

【题目描述】 ICPC 刚刚结束,某校 $m$ 名参赛选手,从 $1$ 到 $m$ 编号,要回去补文化课了。文化课有 $1...n$ 共 $n$ 个知识点。学校安排了两个教师,他们每个人要告诉学生他们要上的 $k$ 个连续的知识点。教师独立选择 $k$ 个连续知识点。两个教师选择的知识点可以重合、相交或根本不相交。第 $i$ 个学生只对 $l_i...r_i$ 的知识点有兴趣。每个学生总是选择只听教师教授的知识点中他感兴趣的最大数量的知识点,令知识这个最大数为 $a_i$。需要注意的是,两个教师是同时开课的,即没有学生可以听两个教师的课,即使他们的知识点没有交叉。两个教师希望自己选择 $k$ 个连续的知识点,使得所有学生的 $a_i$ 之和最大。 【输入】 第一行三个正整数 $n$,$m$,$k$。 接下来 $m$ 行,每行两个正整数 $l_i$,$r_i$。 【输出】 输出 $a_i$ 之和的最大值

加入题单

上一题 下一题 算法标签: