Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <set>
- #include <utility>
- #include <map>
- #include <cmath>
- #include <algorithm>
- #include <stack>
- #include <iomanip>
- #include <string>
- #include <iterator>
- #include <cstring>
- #include <cstdlib>
- #include <queue>
- #define int long long
- #define all(a) a.begin(), a.end()
- #define rall(a) a.rbegin(), a.rend()
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair<int, int> pii;
- ll const INF = 1e18, p = 1e9 + 7;
- void speedup() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- }
- void goDown1(int x, int y) {
- cout << x - 2 << " " << y - 1 << '\n';
- cout << x - 1 << " " << y - 3 << '\n';
- cout << x << " " << y - 1 << '\n';
- }
- void goLeft1(int x, int y) {
- cout << x - 1 << " " << y - 2 << '\n';
- cout << x - 3 << " " << y - 1 << '\n';
- cout << x - 1 << " " << y << '\n';
- }
- void goRight1(int x, int y) {
- cout << x + 1 << " " << y - 2 << '\n';
- cout << x + 3 << " " << y - 1 << '\n';
- cout << x + 1 << " " << y << '\n';
- }
- void goUp1(int x, int y) {
- cout << x - 2 << " " << y + 1 << '\n';
- cout << x - 1 << " " << y + 3 << '\n';
- cout << x << " " << y + 1 << '\n';
- }
- void goDown4(int x, int y) {
- cout << x + 1 << " " << y - 2 << '\n';
- cout << x << " " << y - 4 << '\n';
- }
- void goRight4(int x, int y) {
- cout << x + 2 << " " << y + 1 << '\n';
- cout << x + 4 << " " << y << '\n';
- }
- void goLeft4(int x, int y) {
- cout << x - 2 << " " << y + 1 << '\n';
- cout << x - 4 << " " << y << '\n';
- }
- void goUp4(int x, int y) {
- cout << x + 1 << " " << y + 2 << '\n';
- cout << x << " " << y + 4 << '\n';
- }
- void solve() {
- int n, t, m;
- cin >> t >> n;
- vector <int> a(n), b(n), c(n), d(n);
- vector <pair<int, pii> > scan;
- for (int i = 0; i < n; ++i) {
- int x, y;
- cin >> x >> y;
- scan.push_back({ x, {0, 2} });
- scan.push_back({ y + t, {1, 1} });
- }
- cin >> m;
- for (int i = 0; i < m; ++i) {
- int x, y;
- cin >> x >> y;
- scan.push_back({ x, {1, 2} });
- scan.push_back({ y + t, {0, 1} });
- }
- sort(all(scan));
- /*for (auto x : scan) {
- cout << x.first << " " << x.second.first << " " << x.second.second << '\n';
- }*/
- int s = scan.size();
- vector <int> st(2, 0);
- for (int i = 0; i < s; ++i) {
- if (scan[i].second.second == 2) {
- st[scan[i].second.first] = max(0LL, st[scan[i].second.first] - 1);
- }
- else {
- st[scan[i].second.first]++;
- }
- }
- cout << st[0] + st[1];
- }
- signed main() {
- speedup();
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement