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;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
int main() {
ll n, d; cin >> n >> d;
vector<ll> a(n); for(auto& u : a) cin >> u;
vector<map<ll, ll>> mp(n); //v[place][max]=ans
mp[0][a[0]]=1;
for(ll i=1; i<n; i++){
mp[i][a[i]]=1;
for(ll j=1; j<=d; j++){
if(i>=j){
for(auto& u : mp[i-j]){
if(u.F>=a[i]){
mp[i][u.F]=max(mp[i][u.F], u.S);
}
else{
mp[i][a[i]]=max(mp[i][a[i]], u.S+1);
}
}
}
}
}
ll ans=0;
for(auto& u : mp[n-1]) ans=max(ans, u.S);
cout << ans << endl;
}
# | 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... |