107152024-04-10 11:10:02kidesoTelefonközpontcpp17Time limit exceeded 40/100545ms15592 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()
{
	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
1Accepted3ms1880 KiB
2Accepted3ms2068 KiB
subtask220/20
3Accepted3ms2320 KiB
4Accepted3ms2376 KiB
5Accepted3ms2380 KiB
6Accepted3ms2504 KiB
7Accepted3ms2584 KiB
8Accepted3ms2616 KiB
9Accepted3ms2684 KiB
subtask320/20
10Accepted3ms2320 KiB
11Accepted3ms2376 KiB
12Accepted3ms2380 KiB
13Accepted3ms2504 KiB
14Accepted3ms2584 KiB
15Accepted3ms2616 KiB
16Accepted3ms2684 KiB
17Accepted12ms2944 KiB
18Accepted12ms3076 KiB
19Accepted12ms3160 KiB
20Accepted12ms3404 KiB
21Accepted14ms3500 KiB
22Accepted12ms3364 KiB
23Accepted12ms3648 KiB
subtask40/60
24Accepted3ms2320 KiB
25Accepted3ms2376 KiB
26Accepted3ms2380 KiB
27Accepted3ms2504 KiB
28Accepted3ms2584 KiB
29Accepted3ms2616 KiB
30Accepted3ms2684 KiB
31Accepted12ms2944 KiB
32Accepted12ms3076 KiB
33Accepted12ms3160 KiB
34Accepted12ms3404 KiB
35Accepted14ms3500 KiB
36Accepted12ms3364 KiB
37Accepted12ms3648 KiB
38Time limit exceeded510ms15376 KiB
39Accepted460ms15256 KiB
40Accepted451ms15260 KiB
41Accepted453ms15208 KiB
42Time limit exceeded504ms15468 KiB
43Time limit exceeded545ms15468 KiB
44Time limit exceeded528ms15592 KiB