107172024-04-10 11:13:29kidesoTelefonközpontcpp17Accepted 100/100163ms16580 KiB
// zsebi kodja debug

#include <iostream>
#include <queue>
#include <algorithm>
#define ll long long 
using namespace std;
ll n, m,q;

vector<ll>x,st;

void epit(ll p, ll l, ll r) {
	if (l == r)	{
		st[p] = x[l];
		return;
	}
	ll k = (l + r) / 2;
	epit(2*p, l, k);
	epit(2*p+1, k + 1, r);
	st[p] = max(st[2 * p], st[2 * p + 1]);
}
ll leker(ll p, ll l, ll r, ll a, ll b) {
	if (a <= l && r <= b) {
		return st[p];
	}
	else if (b < l || r < a)return 0;

	ll k = (l + r) / 2;
	return max(leker(2 * p, l, k, a, b), leker(2 * p + 1, k + 1, r, a, b));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> m >> n >> q;
	x.resize(m + 2);
	st.resize(4 * m + 1);
	for (int i = 1; i <= n; i++)
	{
		ll a, b;
		cin >> a >> b;
		x[a]++;
		x[b + 1]--;

	}
	for (int i = 1; i <= m; ++i)
	{
		x[i] += x[i - 1];
	}
	epit(1, 1, m);
	for (int i = 1; i <= q; ++i)
	{
		ll a, b;
		cin >> a >> b;
		cout<<leker(1, 1, m, a, b)<<"\n";
	}

	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2036 KiB
2Accepted3ms2100 KiB
subtask220/20
3Accepted3ms2336 KiB
4Accepted3ms2660 KiB
5Accepted3ms2648 KiB
6Accepted3ms2720 KiB
7Accepted3ms2936 KiB
8Accepted3ms3024 KiB
9Accepted3ms3020 KiB
subtask320/20
10Accepted3ms2336 KiB
11Accepted3ms2660 KiB
12Accepted3ms2648 KiB
13Accepted3ms2720 KiB
14Accepted3ms2936 KiB
15Accepted3ms3024 KiB
16Accepted3ms3020 KiB
17Accepted6ms3272 KiB
18Accepted6ms3440 KiB
19Accepted6ms3648 KiB
20Accepted6ms3960 KiB
21Accepted6ms4044 KiB
22Accepted6ms4264 KiB
23Accepted6ms4472 KiB
subtask460/60
24Accepted3ms2336 KiB
25Accepted3ms2660 KiB
26Accepted3ms2648 KiB
27Accepted3ms2720 KiB
28Accepted3ms2936 KiB
29Accepted3ms3024 KiB
30Accepted3ms3020 KiB
31Accepted6ms3272 KiB
32Accepted6ms3440 KiB
33Accepted6ms3648 KiB
34Accepted6ms3960 KiB
35Accepted6ms4044 KiB
36Accepted6ms4264 KiB
37Accepted6ms4472 KiB
38Accepted163ms16060 KiB
39Accepted160ms16300 KiB
40Accepted158ms16516 KiB
41Accepted158ms16480 KiB
42Accepted160ms16580 KiB
43Accepted158ms16484 KiB
44Accepted160ms16468 KiB