This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define fr first
#define sc second
int n, k, x, qtd[MAXN], val[MAXN];
ll pref[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> x;
for(int i = 0, a, b, c; i < n; i++) {
cin >> a >> c >> b;
qtd[a]++;
qtd[b+1]--;
val[a+c]++;
val[b+1]--;
}
for(int i = 1; i <= 1000; i++) qtd[i] += qtd[i-1];
for(int i = 1; i <= 1000; i++){
val[i] += val[i-1];
if(qtd[i] < k) pref[i] = pref[i-1];
else pref[i] = pref[i-1] + val[i];
}
ll ans = 0;
for(int i = 1; i <= 1000; i++)
ans = max(ans, pref[i+x-1] - pref[i-1]);
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |