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 forr(i, a, b) for (int i = a; i <= b; i++)
#define ford(i, a, b) for (int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(), v.end()
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define file "test"
using namespace std;
const int base = 31;
const ll mod = 1e9 + 7;
const ll oo = 1e18;
const int N = 2e5 + 5;
int h[N], dp[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, M;
cin >> n >> M;
forr(i, 1, n) cin >> h[i];
dp[0] = 1;
forr(i, 0, n){
forr(j, 0, i - 1) {
if (h[i] - h[j] <= M*(i-j) && dp[j]) dp[i] = max(dp[i], dp[j] + 1);
}
}
int res = 0;
forr(i, 0, n) res = max(res, dp[i]);
cout << n - res + 1;
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... |