10731 | 2024-04-10 20:17:25 | zsebi | Telefonközpont | cpp17 | Accepted 100/100 | 165ms | 15848 KiB |
#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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2040 KiB | ||||
2 | Accepted | 3ms | 2248 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2424 KiB | ||||
4 | Accepted | 3ms | 2512 KiB | ||||
5 | Accepted | 3ms | 2604 KiB | ||||
6 | Accepted | 3ms | 2732 KiB | ||||
7 | Accepted | 3ms | 2944 KiB | ||||
8 | Accepted | 3ms | 3116 KiB | ||||
9 | Accepted | 3ms | 3204 KiB | ||||
subtask3 | 20/20 | ||||||
10 | Accepted | 3ms | 2424 KiB | ||||
11 | Accepted | 3ms | 2512 KiB | ||||
12 | Accepted | 3ms | 2604 KiB | ||||
13 | Accepted | 3ms | 2732 KiB | ||||
14 | Accepted | 3ms | 2944 KiB | ||||
15 | Accepted | 3ms | 3116 KiB | ||||
16 | Accepted | 3ms | 3204 KiB | ||||
17 | Accepted | 6ms | 3528 KiB | ||||
18 | Accepted | 6ms | 3772 KiB | ||||
19 | Accepted | 6ms | 3728 KiB | ||||
20 | Accepted | 6ms | 3940 KiB | ||||
21 | Accepted | 6ms | 3860 KiB | ||||
22 | Accepted | 6ms | 3868 KiB | ||||
23 | Accepted | 6ms | 3868 KiB | ||||
subtask4 | 60/60 | ||||||
24 | Accepted | 3ms | 2424 KiB | ||||
25 | Accepted | 3ms | 2512 KiB | ||||
26 | Accepted | 3ms | 2604 KiB | ||||
27 | Accepted | 3ms | 2732 KiB | ||||
28 | Accepted | 3ms | 2944 KiB | ||||
29 | Accepted | 3ms | 3116 KiB | ||||
30 | Accepted | 3ms | 3204 KiB | ||||
31 | Accepted | 6ms | 3528 KiB | ||||
32 | Accepted | 6ms | 3772 KiB | ||||
33 | Accepted | 6ms | 3728 KiB | ||||
34 | Accepted | 6ms | 3940 KiB | ||||
35 | Accepted | 6ms | 3860 KiB | ||||
36 | Accepted | 6ms | 3868 KiB | ||||
37 | Accepted | 6ms | 3868 KiB | ||||
38 | Accepted | 165ms | 15500 KiB | ||||
39 | Accepted | 163ms | 15536 KiB | ||||
40 | Accepted | 158ms | 15564 KiB | ||||
41 | Accepted | 160ms | 15600 KiB | ||||
42 | Accepted | 159ms | 15700 KiB | ||||
43 | Accepted | 158ms | 15848 KiB | ||||
44 | Accepted | 157ms | 15848 KiB |