10817 | 2024-04-15 18:58:14 | bovizdb | Telefonközpont | cpp17 | Wrong answer 0/100 | 199ms | 26276 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--;
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 | 2096 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 3ms | 2452 KiB | ||||
4 | Wrong answer | 3ms | 2412 KiB | ||||
5 | Wrong answer | 3ms | 2664 KiB | ||||
6 | Wrong answer | 3ms | 2988 KiB | ||||
7 | Wrong answer | 3ms | 3216 KiB | ||||
8 | Wrong answer | 3ms | 3420 KiB | ||||
9 | Wrong answer | 3ms | 3748 KiB | ||||
subtask3 | 0/20 | ||||||
10 | Wrong answer | 3ms | 2452 KiB | ||||
11 | Wrong answer | 3ms | 2412 KiB | ||||
12 | Wrong answer | 3ms | 2664 KiB | ||||
13 | Wrong answer | 3ms | 2988 KiB | ||||
14 | Wrong answer | 3ms | 3216 KiB | ||||
15 | Wrong answer | 3ms | 3420 KiB | ||||
16 | Wrong answer | 3ms | 3748 KiB | ||||
17 | Wrong answer | 6ms | 4256 KiB | ||||
18 | Wrong answer | 6ms | 4464 KiB | ||||
19 | Wrong answer | 6ms | 4676 KiB | ||||
20 | Wrong answer | 6ms | 4704 KiB | ||||
21 | Wrong answer | 6ms | 4780 KiB | ||||
22 | Wrong answer | 6ms | 4784 KiB | ||||
23 | Wrong answer | 6ms | 4860 KiB | ||||
subtask4 | 0/60 | ||||||
24 | Wrong answer | 3ms | 2452 KiB | ||||
25 | Wrong answer | 3ms | 2412 KiB | ||||
26 | Wrong answer | 3ms | 2664 KiB | ||||
27 | Wrong answer | 3ms | 2988 KiB | ||||
28 | Wrong answer | 3ms | 3216 KiB | ||||
29 | Wrong answer | 3ms | 3420 KiB | ||||
30 | Wrong answer | 3ms | 3748 KiB | ||||
31 | Wrong answer | 6ms | 4256 KiB | ||||
32 | Wrong answer | 6ms | 4464 KiB | ||||
33 | Wrong answer | 6ms | 4676 KiB | ||||
34 | Wrong answer | 6ms | 4704 KiB | ||||
35 | Wrong answer | 6ms | 4780 KiB | ||||
36 | Wrong answer | 6ms | 4784 KiB | ||||
37 | Wrong answer | 6ms | 4860 KiB | ||||
38 | Wrong answer | 199ms | 25004 KiB | ||||
39 | Wrong answer | 194ms | 26080 KiB | ||||
40 | Wrong answer | 195ms | 25088 KiB | ||||
41 | Wrong answer | 197ms | 25048 KiB | ||||
42 | Wrong answer | 194ms | 25596 KiB | ||||
43 | Wrong answer | 196ms | 26192 KiB | ||||
44 | Wrong answer | 194ms | 26276 KiB |