이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |