Submission #1016951

#TimeUsernameProblemLanguageResultExecution timeMemory
1016951NguyenPhucThangRabbit Carrot (LMIO19_triusis)C++14
63 / 100
1064 ms1652 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...