This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
 *    author:  longvu
 *    created: 10/22/22 20:08:25
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int nax = (int)(100001);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
    if (y > x) {x = y; return true;}
    return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
    if (y < x) {x = y; return true;}
    return false;
}
int n, k, x;
int L[nax], T[nax], R[nax], pre[nax], prep[nax];
int sub1() {
    pre[0] = 0;
    for (int i = 1; i <= n; ++i) {
        pre[L[i]]++;
        pre[R[i] + 1]--;
    }
    for (int i = 1; i < nax; ++i) {
        pre[i] += pre[i - 1];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = L[i] + T[i]; j <= R[i]; ++j) {
            if (pre[j] >= k) {
                prep[j]++;
            }
        }
    }
    for (int i = 1; i < nax; ++i) {
        prep[i] += prep[i - 1];
    }
    int ans = 0;
    for (int i = 1; i + x - 1 < nax; ++i) {
        maximize(ans, prep[i + x - 1] - prep[i - 1]);
    }
    return ans;
}
const bool sub = 1;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> x;
    bool flag_sub1 = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> L[i] >> T[i] >> R[i];
        if (L[i] > 1000 || T[i] > 1000 || R[i] > 1000) {
            flag_sub1 = 0;
        }
    }
    if (n <= 1000 && k <= 1000 && x <= 1000 && flag_sub1) {
        if (!sub) cout << "Sub1: " << '\n';
        cout << sub1() << '\n';
        if (sub) return 0;
    }
    assert(false);
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |