Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <array>
- #include <vector>
- #include <numeric>
- #include <random>
- #include <chrono>
- #include <set>
- #include <map>
- #include <queue>
- #define int long long
- using namespace std;
- const long long INF = 1e9 + 7;
- const int MAXN = 15e4 + 10;
- const int N = 1e5 + 10;
- array<int, MAXN> sq, a, add;
- const int B = 666;
- inline void build(int n) {
- a.fill(0);
- sq.fill(0);
- add.fill(0);
- }
- inline void put(int l, int r) {
- while (l <= r) {
- if (l % B == 0 && l + B - 1 <= r) {
- ++sq[l / B];
- ++add[l / B];
- l += B;
- } else {
- ++a[l];
- sq[l / B] = max(sq[l / B], a[l] + add[l / B]);
- ++l;
- }
- }
- }
- inline int get(int l, int r) {
- int ans = 0;
- while (l <= r) {
- if (l % B == 0 && l + B - 1 <= r) {
- ans = max(ans, sq[l / B]);
- l += B;
- } else {
- ans = max(ans, a[l] + add[l / B]);
- ++l;
- }
- }
- return ans;
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int n, k, m;
- cin >> n >> k >> m;
- build(n - 1);
- while (m--) {
- int l, r;
- cin >> l >> r;
- --r;
- if (get(l, r) < k) {
- cout << "Yes\n";
- put(l, r);
- } else {
- cout << "No\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment