ProgMe

Scam line

Oct 20th, 2023
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | Jokes | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3.  
  4. #define l first
  5. #define r second
  6.  
  7. #define int int64_t
  8. #define double long double
  9.  
  10. using namespace std;
  11. using namespace __gnu_pbds;
  12.  
  13. std::mt19937_64 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
  14. std::uniform_real_distribution<double> rnd_double(0, 1);
  15.  
  16. int nextInt(int r) {  // [0; R)
  17.     return rnd() % r;
  18. }
  19.  
  20. int nextInt(int l, int r) {  // [L; R)
  21.     return l + rnd() % (r - l);
  22. }
  23.  
  24. double nextDouble() {  // [0; 1]
  25.     return rnd_double(rnd);
  26. }
  27.  
  28. double nextDouble(double r) {  // [0; R]
  29.     return r * nextDouble();
  30. }
  31.  
  32. double nextDouble(double l, double r) {  // [L; R]
  33.     return l + (r - l) * nextDouble();
  34. }
  35.  
  36. template <typename T>
  37. using Orset = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag,
  38.         __gnu_pbds::tree_order_statistics_node_update>;
  39.  
  40. template <typename T>
  41. using Ormultiset =
  42.         __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less_equal<T>, __gnu_pbds::rb_tree_tag,
  43.                 __gnu_pbds::tree_order_statistics_node_update>;
  44.  
  45. void runSolve() {
  46.     int n, m;
  47.     cin >> n >> m;
  48.     vector<pair<int, int>> queries;
  49.     while (n--) {
  50.         int l, r;
  51.         cin >> l >> r;
  52.         queries.emplace_back(l, 1);
  53.         queries.emplace_back(r, 3);
  54.     }
  55.     while (m--) {
  56.         int x;
  57.         cin >> x;
  58.         queries.emplace_back(x, 2);
  59.     }
  60.     sort(queries.begin(), queries.end());
  61.  
  62.     int cnt = 0;
  63.     pair<int, int> ans = {-1, -1};
  64.     for (auto [x, type] : queries) {
  65.         if (type == 1) {
  66.             cnt++;
  67.         } else if (type == 2) {
  68.             if (ans.second < cnt) {
  69.                 ans = {x, cnt};
  70.             }
  71.         } else {
  72.             cnt--;
  73.         }
  74.     }
  75.     cout << ans.first << ' ' << ans.second << '\n';
  76. }
  77.  
  78. int32_t main() {
  79.     ios::sync_with_stdio(false);
  80.     cin.tie(nullptr);
  81.     int t = 1;
  82. //    cin >> t;
  83.     while (t--) {
  84.         runSolve();
  85.     }
  86. }
  87.  
Advertisement
Add Comment
Please, Sign In to add comment