Submission #960701

#TimeUsernameProblemLanguageResultExecution timeMemory
960701irmuunRabbit Carrot (LMIO19_triusis)C++17
63 / 100
1010 ms2392 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; int a[n+5]; a[0]=0; for(int i=1;i<=n;i++){ cin>>a[i]; } int dp[n+5]; fill(dp,dp+n+1,1e9); dp[0]=0;//last remaining int ans=n; for(int i=1;i<=n;i++){ for(int j=0;j<i;j++){ if(a[j]+(i-j)*m>=a[i]){ dp[i]=min(dp[i],dp[j]+(i-j-1)); } } ans=min(ans,n-i+dp[i]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...