107142024-04-10 10:32:57zsebiTelefonközpontcpp17Wrong answer 20/100151ms16424 KiB
// telefonkozpont.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#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, n);
	for (int i = 1; i <= q; ++i)
	{
		ll a, b;
		cin >> a >> b;
		cout<<leker(1, 1, n, a, b)<<"\n";
	}

	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1880 KiB
2Accepted3ms2064 KiB
subtask220/20
3Accepted4ms2292 KiB
4Accepted3ms2520 KiB
5Accepted3ms2756 KiB
6Accepted4ms2948 KiB
7Accepted3ms3060 KiB
8Accepted3ms3060 KiB
9Accepted3ms3188 KiB
subtask30/20
10Accepted4ms2292 KiB
11Accepted3ms2520 KiB
12Accepted3ms2756 KiB
13Accepted4ms2948 KiB
14Accepted3ms3060 KiB
15Accepted3ms3060 KiB
16Accepted3ms3188 KiB
17Wrong answer14ms3508 KiB
18Wrong answer12ms3732 KiB
19Wrong answer14ms3860 KiB
20Wrong answer12ms3952 KiB
21Wrong answer12ms4044 KiB
22Wrong answer12ms3960 KiB
23Wrong answer12ms3964 KiB
subtask40/60
24Accepted4ms2292 KiB
25Accepted3ms2520 KiB
26Accepted3ms2756 KiB
27Accepted4ms2948 KiB
28Accepted3ms3060 KiB
29Accepted3ms3060 KiB
30Accepted3ms3188 KiB
31Wrong answer14ms3508 KiB
32Wrong answer12ms3732 KiB
33Wrong answer14ms3860 KiB
34Wrong answer12ms3952 KiB
35Wrong answer12ms4044 KiB
36Wrong answer12ms3960 KiB
37Wrong answer12ms3964 KiB
38Runtime error150ms15876 KiB
39Runtime error148ms15940 KiB
40Runtime error151ms16224 KiB
41Runtime error149ms16148 KiB
42Runtime error150ms16344 KiB
43Runtime error146ms16388 KiB
44Runtime error140ms16424 KiB