107162024-04-10 11:13:01kidesoTelefonközpontcpp17Wrong answer 20/10056ms17100 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, n);
	for (int i = 1; i <= q; ++i)
	{
		ll a, b;
		cin >> a >> b;
		cout<<leker(1, 1, n, a, b)<<"\n";
	}

	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1892 KiB
2Accepted3ms2120 KiB
subtask220/20
3Accepted3ms2312 KiB
4Accepted3ms2520 KiB
5Accepted3ms2864 KiB
6Accepted3ms3072 KiB
7Accepted3ms3156 KiB
8Accepted3ms3368 KiB
9Accepted3ms3584 KiB
subtask30/20
10Accepted3ms2312 KiB
11Accepted3ms2520 KiB
12Accepted3ms2864 KiB
13Accepted3ms3072 KiB
14Accepted3ms3156 KiB
15Accepted3ms3368 KiB
16Accepted3ms3584 KiB
17Wrong answer6ms3912 KiB
18Wrong answer6ms4236 KiB
19Wrong answer6ms4320 KiB
20Wrong answer6ms4548 KiB
21Wrong answer6ms4876 KiB
22Wrong answer4ms4936 KiB
23Wrong answer6ms4884 KiB
subtask40/60
24Accepted3ms2312 KiB
25Accepted3ms2520 KiB
26Accepted3ms2864 KiB
27Accepted3ms3072 KiB
28Accepted3ms3156 KiB
29Accepted3ms3368 KiB
30Accepted3ms3584 KiB
31Wrong answer6ms3912 KiB
32Wrong answer6ms4236 KiB
33Wrong answer6ms4320 KiB
34Wrong answer6ms4548 KiB
35Wrong answer6ms4876 KiB
36Wrong answer4ms4936 KiB
37Wrong answer6ms4884 KiB
38Runtime error56ms16684 KiB
39Runtime error52ms16628 KiB
40Runtime error54ms16628 KiB
41Runtime error56ms16644 KiB
42Runtime error54ms16880 KiB
43Runtime error54ms17100 KiB
44Runtime error52ms17052 KiB