#include <bits/stdc++.h>
using namespace std;
struct person{
int begin;
int pay;
int end;
};
int n, k, x, maxEnd, ans, val[100005], p[100005];
person d[100005];
int main(){
cin >> n >> k >> x;
for (int i = 0; i < n; i++)
{
cin >> d[i].begin >> d[i].pay >> d[i].end;
maxEnd = max(maxEnd, d[i].end);
d[i].begin--;
d[i].end--;
}
for (int i = 0; i < maxEnd; i++)
{
for (int j = 0; j < n; j++)
{
if(i >= d[j].begin && i <= d[j].end){
p[i]++;
}
}
}
for (int i = 0; i < maxEnd; i++)
{
val[i] = val[i - 1];
if(p[i] < k) continue;
for (int j = 0; j < n; j++)
{
if(i > d[j].begin + d[j].pay - 1 && i >= d[j].begin && i <= d[j].end){
//cout << "i " << i << " lim " << d[j].begin + d[j].pay - 1 << " bas " << d[j].begin << " son " << d[j].end << "\n";
val[i]++;
}
}
}
for (int i = 0; i < maxEnd - x; i++)
{
ans = max(ans, val[i + x - 1] - val[i - 1]);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
292 KB |
Output is correct |
4 |
Correct |
1 ms |
284 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |