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>
using namespace std;
#define N 2010
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> pll;
vector<pll>range;
ll sum[N];
void SOMA(ll l,ll r,ll x)
{
ll i;
for(i=l;i<=r;i++)
{
sum[i]+=x;
}
return;
}
int main()
{
ll n,k,x,i=0,l,t,r,pos,val,cur=0,s=0,ans=0;
cin >> n >> k >> x;
while(i<n)
{
cin >> l >> t >> r;
range.pb({l,1});
range.pb({r+1,-1});
range.pb({l+t,2});
range.pb({r+1,-2});
i++;
}
sort(range.begin(),range.end());
i=0;
n*=4;
range.pb({-1,0});
while(i<n)
{
pos=range[i].first;
while(range[i].first==pos)
{
val=range[i].second;
if(val==1)
cur++;
if(val==-1)
cur--;
if(val==2)
s++;
if(val==-2)
s--;
i++;
}
if(cur>=k)
{
SOMA(pos,range[i].first-1,s);
}
}
for(i=1;i<N;i++)
{
sum[i]+=sum[i-1];
if(i>=x)
ans=max(ans,sum[i]-sum[i-x]);
}
cout << ans << endl;
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... |