Submission #1284363

#TimeUsernameProblemLanguageResultExecution timeMemory
1284363tntRabbit Carrot (LMIO19_triusis)C++20
0 / 100
10 ms580 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define s second #define pb push_back #define f first #define int long long #define s second const long long inf = 2e9 + 7; const int N = 4e5 + 101; void solve(){ int n,m; cin >> n >> m; int a[n + 1]; a[0] = 0; for(int i = 1; i <= n; i++){ cin >> a[i]; } vector <int> dp(n + 1,-inf); dp[0] = 0; for(int i = 0; i <= n; i++){ for(int j = 0; j < i; j++){ if(dp[j] < 0) continue; int x; if(m == 0) x = inf; else x = ((a[i] - a[j]) + m - 1) / m; if(a[j] >= a[i] || (i - j) >= x){ if(dp[i] < dp[j] + 1){ dp[i] = dp[j] + 1; } } } } int mx = 0; if(dp[n] == -inf) dp[n] = 0; cout << n - dp[n]; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); //freopen("promote.in", "r", stdin); //freopen("promote.out", "w", stdout); int t = 1; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...