tiom4eg

openol D 100

Jan 16th, 2024
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. // tiom4eg's precompiler options
  3. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  4. // IO settings
  5. #define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
  6. // Quick types
  7. #define ll long long
  8. #define ld long double
  9. //#define ull unsigned long long
  10. #define pii pair <int, int>
  11. #define vi vector <int>
  12. #define mi vector <vector <int>>
  13. // Quick functions
  14. #define endl "\n"
  15. #define F first
  16. #define S second
  17. #define all(a) a.begin(), a.end()
  18. #define sz(a) (int)(a.size())
  19. #define pb push_back
  20. #define mp make_pair
  21. // Quick fors
  22. #define FOR(i, a, b) for (int i = a; i < b; ++i)
  23. #define FORS(i, a, b, c) for (int i = a; i < b; i += c)
  24. #define RFOR(i, a, b) for (int i = a; i >= b; --i)
  25. #define EACH(e, a) for (auto& e : a)
  26. // Pragmas
  27. #ifndef TIOM4EG
  28. #pragma GCC optimize("O3") // let the chaos begin!
  29. #pragma GCC target("avx,avx2,tune=native")
  30. #pragma GCC comment(linker, "/stack:200000000")
  31. #endif
  32. // PBDS
  33. #include <ext/pb_ds/assoc_container.hpp>
  34. #include <ext/pb_ds/tree_policy.hpp>
  35. #define pbds tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
  36. using namespace __gnu_pbds;
  37. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  38. using namespace std;
  39. mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
  40. #define int long long
  41. constexpr int INF = 1e9 + 7, MD = 998244353, MAX = 200007, LG = 19, R = 1 << LG, MOD = 1000000007, MOD2 = 1e9 + 9, B = 256;
  42. const ll INFLL = 1e18 + 7;
  43.  
  44.  
  45. signed main() {
  46.     fastIO;
  47.     int n, t, s; cin >> n >> t >> s;
  48.     vi a(n);
  49.     EACH(e, a) cin >> e;
  50.     function <int(int)> f = [&](int x) { return x >= t ? 0 : (t - x + s - 1) / s; };
  51.     map <int, int> c, p, l, r;
  52.     EACH(e, a) ++c[f(e)];
  53.     for (auto it = c.begin(); it != c.end(); ++it) {
  54.         p[it->F] = it->S;
  55.         if (it != c.begin()) p[it->F] += p[prev(it)->F];
  56.     }
  57.     // min
  58.     for (auto it = c.begin(); it != c.end(); ++it) {
  59.         if (it == c.begin()) l[it->F] = 0;
  60.         else l[it->F] = l[prev(it)->F] + min(it->F - prev(it)->F, p[prev(it)->F] - l[prev(it)->F]);
  61.     }
  62.     // max
  63.     RFOR(i, n - 1, 0) {
  64.         int cf = f(a[i]);
  65.         int delay = n - 1 - i - l[cf];
  66.         r[a[i]] = a.end() - lower_bound(all(a), t - s * (cf + delay)) - 1;
  67.     }
  68.     int q; cin >> q;
  69.     while (q--) {
  70.         int d, i; cin >> d >> i, --i;
  71.         cout << (l[f(d)] <= i && i <= r[d] ? "Yes\n" : "No\n");
  72.     }
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment