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 F first
#define S second
#define in insert
#define er erase
#define pb push_back
#define ppb pop_back()
#define ph push
#define pp pop()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
using namespace std;
int main()
{
d3
ll n , d;
cin >> n >> d;
ll a[n];
for(int i = 0 ; n>i ; i++)
cin >> a[i];
ll ans[n][2];
ans[0][0]=1;
ans[0][1]=1;
for(int i = 1 ; n>i ; i++)
{
ll mx = 0;
ll mx1 = 0;
ll w = 0;
for(int j = max(w,i-d) ; i>j ; j++)
{
mx1=max(mx1,max(ans[j][0],ans[j][1]));
if(a[j]<a[i])
mx=max(mx,ans[j][1]);
}
ans[i][0]=mx1;
ans[i][1]=mx+1;
}
cout << max(ans[n-1][0],ans[n-1][1]);
}
# | 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... |