10820 | 2024-04-15 19:17:36 | bovizdb | Telefonközpont | cpp17 | Wrong answer 0/100 | 217ms | 25912 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)
{
ll res = 0;
while(a <= b)
{
if (a%2 == 1)
res = max(res, tree[a++]);
if (b%2 == 0)
res = max(res, tree[b++]);
if (a > b)
break;
a /= 2;
b /= 2;
}
return res;
}
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 | 2120 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 3ms | 2508 KiB | ||||
4 | Wrong answer | 3ms | 2816 KiB | ||||
5 | Wrong answer | 3ms | 3096 KiB | ||||
6 | Wrong answer | 3ms | 3060 KiB | ||||
7 | Wrong answer | 3ms | 3396 KiB | ||||
8 | Wrong answer | 3ms | 3720 KiB | ||||
9 | Wrong answer | 3ms | 3700 KiB | ||||
subtask3 | 0/20 | ||||||
10 | Wrong answer | 3ms | 2508 KiB | ||||
11 | Wrong answer | 3ms | 2816 KiB | ||||
12 | Wrong answer | 3ms | 3096 KiB | ||||
13 | Wrong answer | 3ms | 3060 KiB | ||||
14 | Wrong answer | 3ms | 3396 KiB | ||||
15 | Wrong answer | 3ms | 3720 KiB | ||||
16 | Wrong answer | 3ms | 3700 KiB | ||||
17 | Wrong answer | 6ms | 3888 KiB | ||||
18 | Wrong answer | 6ms | 4020 KiB | ||||
19 | Wrong answer | 6ms | 4112 KiB | ||||
20 | Wrong answer | 6ms | 4112 KiB | ||||
21 | Wrong answer | 6ms | 4244 KiB | ||||
22 | Wrong answer | 6ms | 4200 KiB | ||||
23 | Wrong answer | 6ms | 4316 KiB | ||||
subtask4 | 0/60 | ||||||
24 | Wrong answer | 3ms | 2508 KiB | ||||
25 | Wrong answer | 3ms | 2816 KiB | ||||
26 | Wrong answer | 3ms | 3096 KiB | ||||
27 | Wrong answer | 3ms | 3060 KiB | ||||
28 | Wrong answer | 3ms | 3396 KiB | ||||
29 | Wrong answer | 3ms | 3720 KiB | ||||
30 | Wrong answer | 3ms | 3700 KiB | ||||
31 | Wrong answer | 6ms | 3888 KiB | ||||
32 | Wrong answer | 6ms | 4020 KiB | ||||
33 | Wrong answer | 6ms | 4112 KiB | ||||
34 | Wrong answer | 6ms | 4112 KiB | ||||
35 | Wrong answer | 6ms | 4244 KiB | ||||
36 | Wrong answer | 6ms | 4200 KiB | ||||
37 | Wrong answer | 6ms | 4316 KiB | ||||
38 | Wrong answer | 217ms | 24492 KiB | ||||
39 | Wrong answer | 212ms | 25668 KiB | ||||
40 | Wrong answer | 211ms | 24772 KiB | ||||
41 | Wrong answer | 215ms | 24780 KiB | ||||
42 | Wrong answer | 211ms | 25372 KiB | ||||
43 | Wrong answer | 210ms | 25912 KiB | ||||
44 | Wrong answer | 210ms | 25816 KiB |