#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int n, k, x;
cin >> n >> k >> x;
vector<pair<int, int>> v;
int people[10005];
for(int i = 0; i < n ; i++) {
int l, t, r;
cin >> l>> t >> r;
for(int j = l; j <= r; j++) people[j] ++;
l += t;
if(r >= l) {
v.push_back({l, r});
}
}
int naughtypeople[10005];
for(pair<int, int> i : v) {
for(int j = i.first; j<= i.second; j++) naughtypeople[j]++;
}
int maxval = 0;
int total = 0;
for(int i = 0; i < x; i++) {
if(people[i] >= k) {
total += naughtypeople[i];
}
}
maxval = total;
for(int i = x; i < 10005; i++) {
if(people[i] >= k) {
total += naughtypeople[i];
}
if(people[i-x] >= k) {
total -= naughtypeople[i-x];
}
maxval = max(maxval, total);
}
cout<<maxval<<'\n';
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... |