AT_ndpc2026_e.Summer Vacation
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Your summer vacation starts today and lasts for N days.
There are M events. The i-th event starts on the morning of day Ai and ends on the evening of day Bi.
You are given Q queries. In each query, you are given two integers L and R, and you need to answer the following:
You decide to attend as many events as possible during the period from day L to day R.
However, you cannot join or leave an event in the middle. Therefore, you cannot attend multiple events whose time periods overlap, and you also cannot attend any event that starts before day L or ends after day R.
If you choose the events optimally, what is the maximum number of events you can attend?
你的暑假从今天开始,持续 N 天。
共有 M 个活动。第 i 个活动从第 Ai 天的早晨开始,到第 Bi 天的晚上结束。
你将收到 Q 个查询。每个查询给出两个整数 L 和 R,你需要回答以下问题:
你决定在第 L 天至第 R 天期间尽可能多地参加活动。
然而,你不能在活动中途加入或离开。因此,你不能参加时间区间重叠的多个活动,也不能参加任何开始时间早于第 L 天或结束时间晚于第 R 天的活动。
若你最优地选择活动,最多能参加多少个活动?
输入格式
The input is given from standard input in the following format:
N M Q
A1 B1
A2 B2
⋮
AM BM
query1
query2
⋮
queryQ
Each query is given in the following format:
L R
输入从标准输入中按以下格式给出:
N M Q
A1 B1
A2 B2
⋮
AM BM
query1
query2
⋮
queryQ
每个查询按以下格式给出:
L R
输出格式
Print Q lines. For the i-th line, output the answer to the i-th query.
输出 Q 行。对于第 i 行,输出第 i 个查询的答案。
输入输出样例
输入#1
5 3 3 1 3 4 5 2 2 1 5 1 1 3 5
输出#1
2 0 1
输入#2
9 13 8 4 6 1 5 8 9 5 6 1 7 4 9 4 6 2 8 5 6 5 8 2 6 3 7 1 3 5 7 5 7 5 7 3 4 1 8 2 6 6 8 8 9
输出#2
1 1 1 0 2 1 0 1
说明/提示
Sample 1 Explanation:
For example, in the first query, you can attend the 1st and 2nd events, and this is the maximum.
Constraints
- 1≤N≤2×105
- 1≤M≤2×105
- 1≤Q≤2×105
- 1≤Ai≤Bi≤N
- 1≤L≤R≤N
- All input values are integers
样例 1 解释:
例如,在第一个查询中,你可以参加第 1 场和第 2 场活动,这是可参加活动的最大数量。
约束条件
- 1≤N≤2×105
- 1≤M≤2×105
- 1≤Q≤2×105
- 1≤Ai≤Bi≤N
- 1≤L≤R≤N
- 所有输入值均为整数
输入解题思路,AI测评打分。不知道怎么写?