比赛 |
树立信心的模拟赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
凯伦和咖啡 |
最终得分 |
100 |
用户昵称 |
胡嘉兴 |
运行时间 |
0.323 s |
代码语言 |
C++ |
内存使用 |
1.82 MiB |
提交时间 |
2017-09-01 21:32:35 |
显示代码纯文本
#include <cstdio>
using namespace std;
#define N 200000 + 117
int s[N] = {0}, book[N] = {0};
int main()
{
int n, k, q, t;
freopen("coffee.in", "r", stdin);
freopen("coffee.out", "w", stdout);
scanf("%d%d%d", &n, &k, &q);
for(int i = 1; i <= n; i++)
{
int l, r;
scanf("%d%d", &l, &r);
book[l]++;
book[r + 1]--;
}
for(int i=1; i <= N; i++)
{
book[i] = book[i - 1] + book[i];
if(book[i] < k)
{
t=0;
}
else if(book[i] >= k)
{
t=1;
}
s[i] = s[i - 1] + t;
}
for(int i = 1; i <= q; i++)
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", s[b] - s[a - 1]);
}
fclose(stdin);
fclose(stdout);
return 0;
}