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>
#define ll long long
#define pb push_back
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) (int)x.size()
#define fi first
#define sd second
#define all(x) x.begin(), x.end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = (int)1e5 + 500;
int n, k, x;
int skok[N], ans = -1, in[N], out[N], pref[N];
int main()
{
ios::sync_with_stdio(0); cin.tie(NULL);
cin >> n >> k >> x;
for(int i = 1; i <= n; i++)
{
int l, t, r;
cin >> l >> t >> r;
in[l]++; out[r]++;
skok[l + t]++;
}
int cnt = 0, sum = 0, cur = 0;
for(int i = 1; i < N; i++)
{
cnt += in[i];
cur += skok[i];
//cout << cnt << ' ' << cur << ' ' << i << endl;
if (cnt >= k) sum += cur;
cnt -= out[i];
cur -= out[i];
pref[i] = sum;
//ans = max(ans, sum);
}
for(int i = x; i < N; i++) ans = max(ans, pref[i] - pref[i - x]);
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |