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 rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
const int inf = 2e9;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, d; cin >> n >> d;
int a[n+1] = {};
rep (i,1,n) cin >> a[i];
int dp[n+1][n+1] = {};
rep (i,1,n) rep (j,1,n) dp[i][j] = inf;
rep (i,1,n) {
dp[i][1] = a[i];
rep (j,max(i-d,1),i-1) {
rep (k,1,n-1) {
if (dp[j][k]!=-1) {
if (dp[j][k]<a[i]) dp[i][k+1] = min(dp[i][k+1], a[i]);
else dp[i][k] = min(dp[i][k], dp[j][k]);
}
}
}
}
rep (i,1,n) {
if (dp[n][i]==inf) {
cout << i-1 << "\n";
return 0;
}
}
cout << n << "\n";
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |