Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.50 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <vector>
  5. #include <set>
  6. #include <utility>
  7. #include <map>
  8. #include <cmath>
  9. #include <algorithm>
  10. #include <stack>
  11. #include <iomanip>
  12. #include <string>
  13. #include <iterator>
  14. #include <cstring>
  15. #include <cstdlib>
  16. #include <queue>
  17.  
  18. #define int long long
  19. #define all(a) a.begin(), a.end()
  20. #define rall(a) a.rbegin(), a.rend()
  21. using namespace std;
  22.  
  23. typedef long long ll;
  24. typedef long double ld;
  25. typedef pair<int, int> pii;
  26.  
  27. ll const INF = 1e18, p = 1e9 + 7;
  28.  
  29. void speedup() {
  30.     ios_base::sync_with_stdio(0);
  31.     cin.tie(0);
  32.     cout.tie(0);
  33. }
  34.  
  35. void goDown1(int x, int y) {
  36.     cout << x - 2 << " " << y - 1 << '\n';
  37.     cout << x - 1 << " " << y - 3 << '\n';
  38.     cout << x << " " << y - 1 << '\n';
  39. }
  40.  
  41. void goLeft1(int x, int y) {
  42.     cout << x - 1 << " " << y - 2 << '\n';
  43.     cout << x - 3 << " " << y - 1 << '\n';
  44.     cout << x - 1 << " " << y << '\n';
  45. }
  46.  
  47. void goRight1(int x, int y) {
  48.     cout << x + 1 << " " << y - 2 << '\n';
  49.     cout << x + 3 << " " << y - 1 << '\n';
  50.     cout << x + 1 << " " << y << '\n';
  51. }
  52.  
  53. void goUp1(int x, int y) {
  54.     cout << x - 2 << " " << y + 1 << '\n';
  55.     cout << x - 1 << " " << y + 3 << '\n';
  56.     cout << x << " " << y + 1 << '\n';
  57. }
  58.  
  59. void goDown4(int x, int y) {
  60.     cout << x + 1 << " " << y - 2 << '\n';
  61.     cout << x << " " << y - 4 << '\n';
  62. }
  63.  
  64. void goRight4(int x, int y) {
  65.     cout << x + 2 << " " << y + 1 << '\n';
  66.     cout << x + 4 << " " << y << '\n';
  67. }
  68.  
  69. void goLeft4(int x, int y) {
  70.     cout << x - 2 << " " << y + 1 << '\n';
  71.     cout << x - 4 << " " << y << '\n';
  72. }
  73.  
  74. void goUp4(int x, int y) {
  75.     cout << x + 1 << " " << y + 2 << '\n';
  76.     cout << x << " " << y + 4 << '\n';
  77. }
  78.  
  79. void solve() {
  80.     int n, t, m;
  81.     cin >> t >> n;
  82.     vector <int> a(n), b(n), c(n), d(n);
  83.     vector <pair<int, pii> > scan;
  84.     for (int i = 0; i < n; ++i) {
  85.         int x, y;
  86.         cin >> x >> y;
  87.         scan.push_back({ x, {0, 2} });
  88.         scan.push_back({ y + t, {1, 1} });
  89.     }
  90.  
  91.     cin >> m;
  92.     for (int i = 0; i < m; ++i) {
  93.         int x, y;
  94.         cin >> x >> y;
  95.         scan.push_back({ x, {1, 2} });
  96.         scan.push_back({ y + t, {0, 1} });
  97.     }
  98.     sort(all(scan));
  99.     /*for (auto x : scan) {
  100.         cout << x.first << " " << x.second.first << " " << x.second.second << '\n';
  101.     }*/
  102.     int s = scan.size();
  103.     vector <int> st(2, 0);
  104.     for (int i = 0; i < s; ++i) {
  105.         if (scan[i].second.second == 2) {
  106.             st[scan[i].second.first] = max(0LL, st[scan[i].second.first] - 1);
  107.         }
  108.         else {
  109.             st[scan[i].second.first]++;
  110.         }
  111.     }
  112.     cout << st[0] + st[1];
  113. }
  114.  
  115. signed main() {
  116.     speedup();
  117.     solve();
  118.     return 0;
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement