10819 | 2024-04-15 19:14:44 | bovizdb | Telefonközpont | cpp17 | Wrong answer 0/100 | 200ms | 25888 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define fs first
#define sc second
#define vll vector<ll>
#define v2ll vector<vll>
ll m, n, q;
priority_queue<pll> calls;
priority_queue<ll> finish;
vll tree;
ll ans(ll a, ll b)
{
while(a < b)
{
if (a%2 == 1)
a++;
if (b%2 == 0)
b--;
if (a > b)
break;
a /= 2;
b /= 2;
}
return tree[a];
}
void solve()
{
cin >> m >> n >> q;
ll k = 1;
while(k < m)
k *= 2;
tree.resize(2*k);
for (ll i = 0; i < n; i++)
{
ll k, v;
cin >> k >> v;
k--; v--;
calls.push({-k, -v});
}
ll pcs = 0;
for (ll i = 0; i < m; i++)
{
while(!calls.empty() && -(calls.top().fs) == i)
{
pcs++;
finish.push(calls.top().sc);
calls.pop();
}
while(finish.size() > 0 && -finish.top() < i)
{
pcs--;
finish.pop();
}
tree[k+i] = pcs;
}
for (ll i = 2*k-1; i > 0; i-=2)
{
tree[i/2] = max(tree[i], tree[i-1]);
}
for (ll i = 0; i < q; i++)
{
ll l, r;
cin >> l >> r;
l--; r--;
cout << ans(l+k, r+k) << "\n";
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll t = 1;
//cin >> t;
while(t--)
{
solve();
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1892 KiB | ||||
2 | Wrong answer | 3ms | 2084 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 3ms | 2200 KiB | ||||
4 | Wrong answer | 3ms | 2520 KiB | ||||
5 | Wrong answer | 3ms | 2664 KiB | ||||
6 | Wrong answer | 3ms | 2876 KiB | ||||
7 | Wrong answer | 3ms | 3208 KiB | ||||
8 | Wrong answer | 3ms | 3152 KiB | ||||
9 | Wrong answer | 3ms | 3372 KiB | ||||
subtask3 | 0/20 | ||||||
10 | Wrong answer | 3ms | 2200 KiB | ||||
11 | Wrong answer | 3ms | 2520 KiB | ||||
12 | Wrong answer | 3ms | 2664 KiB | ||||
13 | Wrong answer | 3ms | 2876 KiB | ||||
14 | Wrong answer | 3ms | 3208 KiB | ||||
15 | Wrong answer | 3ms | 3152 KiB | ||||
16 | Wrong answer | 3ms | 3372 KiB | ||||
17 | Wrong answer | 6ms | 3676 KiB | ||||
18 | Wrong answer | 6ms | 3796 KiB | ||||
19 | Wrong answer | 6ms | 3776 KiB | ||||
20 | Wrong answer | 6ms | 3548 KiB | ||||
21 | Wrong answer | 6ms | 3672 KiB | ||||
22 | Wrong answer | 6ms | 3680 KiB | ||||
23 | Wrong answer | 6ms | 3928 KiB | ||||
subtask4 | 0/60 | ||||||
24 | Wrong answer | 3ms | 2200 KiB | ||||
25 | Wrong answer | 3ms | 2520 KiB | ||||
26 | Wrong answer | 3ms | 2664 KiB | ||||
27 | Wrong answer | 3ms | 2876 KiB | ||||
28 | Wrong answer | 3ms | 3208 KiB | ||||
29 | Wrong answer | 3ms | 3152 KiB | ||||
30 | Wrong answer | 3ms | 3372 KiB | ||||
31 | Wrong answer | 6ms | 3676 KiB | ||||
32 | Wrong answer | 6ms | 3796 KiB | ||||
33 | Wrong answer | 6ms | 3776 KiB | ||||
34 | Wrong answer | 6ms | 3548 KiB | ||||
35 | Wrong answer | 6ms | 3672 KiB | ||||
36 | Wrong answer | 6ms | 3680 KiB | ||||
37 | Wrong answer | 6ms | 3928 KiB | ||||
38 | Wrong answer | 200ms | 24304 KiB | ||||
39 | Wrong answer | 197ms | 25296 KiB | ||||
40 | Wrong answer | 195ms | 24592 KiB | ||||
41 | Wrong answer | 195ms | 24584 KiB | ||||
42 | Wrong answer | 199ms | 25092 KiB | ||||
43 | Wrong answer | 197ms | 25508 KiB | ||||
44 | Wrong answer | 197ms | 25888 KiB |