Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&...values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- 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 plli = pair<pll, int>;
- int n, m;
- pll rng[200003];
- plli srng[200003];
- int main(int argc, char **argv)
- {
- scanf("%d%d", &n, &m);
- for (int i = 1; i <= n; ++i)
- scanf("%lld%lld", &rng[i].first, &rng[i].second);
- for (int i = 1; i < n; ++i)
- srng[i].first.first = rng[i + 1].first - rng[i].second, srng[i].first.second = rng[i + 1].second - rng[i].first,
- srng[i].second = i;
- sort(srng + 1, srng + n);
- pll a;
- mpq<pll> pq;
- for (int i = 1; i <= m; ++i)
- scanf("%lld", &a.first), a.second = i, pq.push(a);
- bool succ = true;
- vector<int> ans(n);
- for (int i = 1; i < n; ++i) {
- const auto &bg = srng[i];
- dbg(bg.first.first, bg.first.second, bg.second);
- if (pq.empty()) {
- succ = false;
- goto fail;
- }
- auto h = pq.top();
- dbg(h.first, h.second);
- pq.pop();
- test:
- if (h.first > bg.first.second) {
- succ = false;
- goto fail;
- }
- if (h.first < bg.first.first) {
- if (pq.empty()) {
- succ = false;
- goto fail;
- } else {
- h = pq.top();
- dbg(h.first, h.second);
- pq.pop();
- goto test;
- }
- }
- ans[bg.second] = h.second;
- }
- fail:
- if (succ) {
- printf("Yes\n");
- for (int i = 1; i < ans.size(); ++i) {
- printf("%d ", ans[i]);
- }
- printf("\n");
- } else {
- printf("No\n");
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement