fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(int argc, char **argv) {
  5. #ifndef ONLINE_JUDGE
  6. freopen("a.in", "r", stdin);
  7. #endif
  8. int n, m;
  9. cin >> n >> m;
  10. vector<pair<long long, long long> > arr(n);
  11. for (int i = 0; i < n; ++i)
  12. cin >> arr[i].first >> arr[i].second;
  13. vector<pair<long long, long long> > diff;
  14. for (int i = 1; i < n; ++i) {
  15. diff.push_back(
  16. make_pair(arr[i].first - arr[i - 1].second,
  17. arr[i].second - arr[i - 1].first));
  18. }
  19. vector<pair<long long, int> > lst(m);
  20. for (int i = 0; i < m; ++i)
  21. cin >> lst[i].first, lst[i].second = i + 1;
  22. sort(lst.begin(), lst.end());
  23. vector<int> ans;
  24. for (int i = 0; i < diff.size(); ++i) {
  25. int l = 0, r = lst.size() - 1;
  26. int best = -1;
  27. while (l <= r) {
  28. int mid = (l + r) / 2;
  29. if (lst[mid].first >= diff[i].first
  30. && lst[mid].first <= diff[i].second) {
  31. best = mid;
  32. l = mid + 1;
  33. } else {
  34. r = mid - 1;
  35. }
  36. }
  37. if (best == -1) {
  38. cout << "No";
  39. return 0;
  40. }
  41. ans.push_back(lst[best].second);
  42. lst.erase(lst.begin() + best);
  43. }
  44. cout << "Yes\n";
  45. copy(ans.begin(),ans.end(),ostream_iterator<int>(cout," "));
  46.  
  47. return 0;
  48. }
  49.  
Runtime error #stdin #stdout #stderr 0s 4124KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc