Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #ifdef __DEBUG__
- #include "dbg.h"
- #else
- #define dbg(...) 42
- #endif
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vl = vector<ll>;
- using vi = vector<int>;
- int main(int argc, char **argv)
- {
- int w, h, n, a, b;
- cin >> w >> h >> n;
- using a2i = array<int, 2>;
- vector<a2i> pts(n);
- for (auto &pt : pts)
- cin >> pt[1] >> pt[0];
- sort(pts.begin(), pts.end());
- cin >> a;
- vi as(a);
- for (auto &x : as)
- cin >> x;
- cin >> b;
- vi bs(b);
- for (auto &x : bs)
- cin >> x;
- as.push_back(INT_MAX);
- bs.push_back(INT_MAX);
- const int len = bs.size();
- ll maxv = INT_MIN, minv = INT_MAX;
- for (int i = 0, j = 0, ny = as[i]; i < as.size(); ++i, ny = as[i]) {
- int nb = 0;
- ll block_cnt = 0;
- while (j < n && pts[j][0] < ny) {
- int pos = upper_bound(bs.begin(), bs.end(), pts[j][1]) - bs.begin();
- while (j < n && pts[j][0] < ny && nb == pos) {
- ++block_cnt;
- ++j;
- pos = upper_bound(bs.begin(), bs.end(), pts[j][1]) - bs.begin();
- }
- minv = min(minv, block_cnt);
- maxv = max(maxv, block_cnt);
- if (pos - nb > 1)
- minv = 0;
- nb = pos, block_cnt = 0;
- }
- }
- cout << minv << ' ' << maxv << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement