题目问你:给你n,k,q 给n个区间,有多少个区间重叠k次以上,求这些区间在询问区间内点的数目。。可以秒想到的是算贡献。。。左边+1,(r+1)的贡献-1. 然后就是扫一遍 记录一些贡献的前缀和,然后可以再扫一遍,记录满足的点的数量的前缀和,然后o1输出就好
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <bitset>
#include <set>
#include <vector>
#include <functional>
using namespace std;
#define pi acos(-1)
#define endl '\n'
#define rand() srand(time(0));
#define me(x) memset(x,0,sizeof(x));
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define close() ios::sync_with_stdio(0);
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL LINF=0x3f3f3f3f3f3f3f3fLL;
//const int dx[]={-1,0,1,0,-1,-1,1,1};
//const int dy[]={0,1,0,-1,1,-1,1,-1};
const int maxn=1e6+5;
const int maxx=1e6+3;
const double EPS=1e-7;
const int MOD=10000007;
typedef pair<int, int>P;
#define mod(x) ((x)%MOD);
template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}
template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}
template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}
template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}
//typedef tree<pt,null_type,less< pt >,rb_tree_tag,tree_order_statistics_node_update> rbtree;
/*lch[root] = build(L1,p-1,L2+1,L2+cnt);
rch[root] = build(p+1,R1,L2+cnt+1,R2);中前*/
/*lch[root] = build(L1,p-1,L2,L2+cnt-1);
rch[root] = build(p+1,R1,L2+cnt,R2-1);中后*/
long long gcd(long long a , long long b){if(b==0) return a;a%=b;return gcd(b,a);}
int vis[maxx],ss[maxx],sum[maxx];
int main()
{
int n,k,q;
scanf("%d%d%d",&n,&k,&q);
for(int i=1;i<=n;i++)
{
int l,r;
scanf("%d%d",&l,&r);
vis[l]++;vis[r+1]--;
}
for(int i=1;i<=maxx-50;i++)
{
sum[i]=sum[i-1]+vis[i];
ss[i]=ss[i-1];
if(sum[i]>=k)
ss[i]++;
}
for(int i=1;i<=q;i++)
{
int l,r;
scanf("%d%d",&l,&r);
printf("%d\n",(ss[r]-ss[l-1]) );
}
}