https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/08/Codeforces-Round-419-Div-2-problem-B-Karen-and-Coffee-Solution-In-CC1.png?fit=640%2C360

Codeforces Round #419 (Div. 2), problem: (B) Karen and Coffee Solution In C/C++

#include <bits/stdc++.h>
using namespace std;
const int N=200007;
int n,k,q,a,b,p[N],c[N],i;
int main(){
cin>>n>>k>>q;
for(i=0;i<n;i++)cin>>a>>b,p[a]++,p[b+1]–;
for(i=1;i<N;i++)p[i]+=p[i-1],c[i]+=c[i-1]+(p[i]>=k);
for(i=0;i<q;i++){cin>>a>>b;cout<<c[b]-c[a-1]<<‘\n’; }
}

(Visited 46 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: