10715 | 2024-04-10 11:10:02 | kideso | Telefonközpont | cpp17 | Time limit exceeded 40/100 | 545ms | 15592 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1880 KiB | ||||
2 | Accepted | 3ms | 2068 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2320 KiB | ||||
4 | Accepted | 3ms | 2376 KiB | ||||
5 | Accepted | 3ms | 2380 KiB | ||||
6 | Accepted | 3ms | 2504 KiB | ||||
7 | Accepted | 3ms | 2584 KiB | ||||
8 | Accepted | 3ms | 2616 KiB | ||||
9 | Accepted | 3ms | 2684 KiB | ||||
subtask3 | 20/20 | ||||||
10 | Accepted | 3ms | 2320 KiB | ||||
11 | Accepted | 3ms | 2376 KiB | ||||
12 | Accepted | 3ms | 2380 KiB | ||||
13 | Accepted | 3ms | 2504 KiB | ||||
14 | Accepted | 3ms | 2584 KiB | ||||
15 | Accepted | 3ms | 2616 KiB | ||||
16 | Accepted | 3ms | 2684 KiB | ||||
17 | Accepted | 12ms | 2944 KiB | ||||
18 | Accepted | 12ms | 3076 KiB | ||||
19 | Accepted | 12ms | 3160 KiB | ||||
20 | Accepted | 12ms | 3404 KiB | ||||
21 | Accepted | 14ms | 3500 KiB | ||||
22 | Accepted | 12ms | 3364 KiB | ||||
23 | Accepted | 12ms | 3648 KiB | ||||
subtask4 | 0/60 | ||||||
24 | Accepted | 3ms | 2320 KiB | ||||
25 | Accepted | 3ms | 2376 KiB | ||||
26 | Accepted | 3ms | 2380 KiB | ||||
27 | Accepted | 3ms | 2504 KiB | ||||
28 | Accepted | 3ms | 2584 KiB | ||||
29 | Accepted | 3ms | 2616 KiB | ||||
30 | Accepted | 3ms | 2684 KiB | ||||
31 | Accepted | 12ms | 2944 KiB | ||||
32 | Accepted | 12ms | 3076 KiB | ||||
33 | Accepted | 12ms | 3160 KiB | ||||
34 | Accepted | 12ms | 3404 KiB | ||||
35 | Accepted | 14ms | 3500 KiB | ||||
36 | Accepted | 12ms | 3364 KiB | ||||
37 | Accepted | 12ms | 3648 KiB | ||||
38 | Time limit exceeded | 510ms | 15376 KiB | ||||
39 | Accepted | 460ms | 15256 KiB | ||||
40 | Accepted | 451ms | 15260 KiB | ||||
41 | Accepted | 453ms | 15208 KiB | ||||
42 | Time limit exceeded | 504ms | 15468 KiB | ||||
43 | Time limit exceeded | 545ms | 15468 KiB | ||||
44 | Time limit exceeded | 528ms | 15592 KiB |