#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, K, X;
cin >> N >> K >> X;
vector<tuple<int, int, int>> sweep;
for (int i = 0; i < N; i++)
{
int L, T, R;
cin >> L >> T >> R;
T = min(L+T-1, R);
sweep.emplace_back(L, 0, -1);
sweep.emplace_back(T+1, 1, -1);
sweep.emplace_back(R+1, 2, -1);
sweep.emplace_back(T, 3, 3*i); sweep.emplace_back(T+X, 4, 3*i);
sweep.emplace_back(R-X, 3, 3*i + 1); sweep.emplace_back(R, 4, 3*i + 1);
sweep.emplace_back(L-1, 3, 3*i + 2); sweep.emplace_back(L+X-1, 4, 3*i + 2);
}
vector<int> possResp(3*N);
sort(sweep.begin(), sweep.end());
int totPeople = 0, totPaying = 0, totPay = 0, lastX = 0, resp = 0;
for (auto [x, type, id] : sweep)
{
// cerr << "x: " << x << ", totPeople: " << totPeople << ", totPaying: " << totPaying << ", totPay: " << totPay << '\n';
if (type == 0) totPeople++;
else if (type == 1) totPaying++;
else if (type == 2) totPeople--, totPaying--;
else if (type == 3)
{
possResp[id] = totPay;
totPay += (int)(totPeople >= K) * totPaying * (x - lastX);
lastX = x;
}
else
{
totPay += (int)(totPeople >= K) * totPaying * (x - lastX);
lastX = x;
resp = max(resp, totPay - possResp[id]);
}
}
cout << resp << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |