Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define pii pair<int, int>
- #define pb push_back
- #define mp make_pair
- #define f first
- #define s second
- using namespace __gnu_pbds;
- using namespace std;
- typedef long long ll;
- const int INF = (int) 1e9 + 7;
- const int MAXN = (int) 1e6 + 7;
- typedef
- tree<
- pii,
- null_type,
- less<pii>,
- rb_tree_tag,
- tree_order_statistics_node_update>
- ordered_set;
- int n, m, len;
- pii p[MAXN];
- pii q[MAXN];
- int main() {
- #ifdef LOCAL
- freopen("in", "r", stdin);
- #endif
- scanf("%d%d%d", &n, &m, &len);
- for (int i = 1; i <= n; i++)
- scanf("%d%d", &p[i].f, &p[i].s);
- for (int i = 1; i <= m; i++)
- scanf("%d%d", &q[i].f, &q[i].s);
- sort(p + 1, p + n + 1);
- sort(q + 1, q + m + 1);
- int l = 1, r = 1;
- int ans = 0;
- ordered_set all;
- for (int i = 1; i <= m; i++) {
- while (r <= n && p[r].f <= q[i].f) {
- all.insert(mp(p[r].s, r));
- r++;
- }
- while (l <= n && p[l].f + len < q[i].f) {
- all.erase(mp(p[l].s, l));
- l++;
- }
- int total = all.order_of_key(mp(q[i].s, INF));
- int bad = all.order_of_key(mp(q[i].s - len, -INF));
- ans = max(ans, total - bad);
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement