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 int long long
int n,d,lim;
int t[2000005];
bool blocat[2000005];
int tole[2000005];
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>d>>lim;
for(int i=1;i<=n;i++)
{
cin>>t[i];
for(int j=i;j>0;j--)
{
if(t[j] + (i-j) <= lim)
{
tole[i] = j;
break;
}
}
}
vector<pair<int,int>> v;
for(int i=1;i<=n;i++)
{
int cnt=0;
for(int j=i;j<=n;j++)
if(tole[j]==i)
cnt++;
v.push_back({cnt,i});
}
sort(v.begin(),v.end());
for(int i=1;i<=d;i++)
{
blocat[v[n-i].second]=1;
}
int rez=0;
for(int i=1;i<=n;i++)
{
for(int j=i;j>0;j--)
{
if(t[j] + (i-j) <= lim)
{
rez++;
break;
}
if(blocat[j-1])
break;
}
}
cout<<rez;
return 0;
}
/*
pentru fiecare pozitie i ne intereseaza doar cea mai din dreapta pozitie j aflata in stanga ei care respecta
j <= i
t[j] + (i-j) <= lim
t[j] - j <= lim - i
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |