#include <bits/stdc++.h>
using namespace std;
struct person{
long long begin;
long long pay;
long long end;
};
long long 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; i++)
{
cout << val[i] << " ";
}
cout << "\n"; */
for (int i = 0; i < maxEnd - x + 1; i++)
{
ans = max(ans, val[i + x - 1] - val[i - 1]);
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
5 ms |
308 KB |
Output is correct |
13 |
Correct |
5 ms |
360 KB |
Output is correct |
14 |
Correct |
4 ms |
308 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
4 ms |
356 KB |
Output is correct |
17 |
Correct |
5 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
308 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
5 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
5 ms |
308 KB |
Output is correct |
13 |
Correct |
5 ms |
360 KB |
Output is correct |
14 |
Correct |
4 ms |
308 KB |
Output is correct |
15 |
Correct |
4 ms |
336 KB |
Output is correct |
16 |
Correct |
4 ms |
356 KB |
Output is correct |
17 |
Correct |
5 ms |
332 KB |
Output is correct |
18 |
Correct |
4 ms |
308 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
5 ms |
332 KB |
Output is correct |
21 |
Execution timed out |
1008 ms |
5632 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |