A13337 | Happy New Year
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Being Santa Claus is very difficult. Sometimes you have to deal with difficult situations.
Today Santa Claus came to the holiday and there were $m$ children lined up in front of him. Let's number them from $1$ to $m$ . Grandfather Frost knows $n$ spells. The $i$ -th spell gives a candy to every child whose place is in the $[L_i, R_i]$ range. Each spell can be used at most once. It is also known that if all spells are used, each child will receive at most $k$ candies.
It is not good for children to eat a lot of sweets, so each child can eat no more than one candy, while the remaining candies will be equally divided between his (or her) Mom and Dad. So it turns out that if a child would be given an even amount of candies (possibly zero), then he (or she) will be unable to eat any candies and will go sad. However, the rest of the children (who received an odd number of candies) will be happy.
Help Santa Claus to know the maximum number of children he can make happy by casting some of his spells.
Today Santa Claus came to the holiday and there were $m$ children lined up in front of him. Let's number them from $1$ to $m$ . Grandfather Frost knows $n$ spells. The $i$ -th spell gives a candy to every child whose place is in the $[L_i, R_i]$ range. Each spell can be used at most once. It is also known that if all spells are used, each child will receive at most $k$ candies.
It is not good for children to eat a lot of sweets, so each child can eat no more than one candy, while the remaining candies will be equally divided between his (or her) Mom and Dad. So it turns out that if a child would be given an even amount of candies (possibly zero), then he (or she) will be unable to eat any candies and will go sad. However, the rest of the children (who received an odd number of candies) will be happy.
Help Santa Claus to know the maximum number of children he can make happy by casting some of his spells.
输入格式
The first line contains three integers of $n$ , $m$ , and $k$ ( $1 \leq n \leq 100\,000, 1 \leq m \leq 10^9, 1 \leq k \leq 8$ ) — the number of spells, the number of children and the upper limit on the number of candy a child can get if all spells are used, respectively.
This is followed by $n$ lines, each containing integers $L_i$ and $R_i$ ( $1 \leq L_i \leq R_i \leq m$ ) — the parameters of the $i$ spell.
This is followed by $n$ lines, each containing integers $L_i$ and $R_i$ ( $1 \leq L_i \leq R_i \leq m$ ) — the parameters of the $i$ spell.
输出格式
Print a single integer — the maximum number of children that Santa can make happy.
输入输出样例
输入 #1
3 5 3 1 3 2 4 3 5
输出 #1
4
In the first example, Santa should apply the first and third spell. In this case all children will be happy except the third.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted