Submission #333295

#TimeUsernameProblemLanguageResultExecution timeMemory
333295AmineTrabelsiRabbit Carrot (LMIO19_triusis)C++14
14 / 100
1103 ms86856 KiB
#include "bits/stdc++.h" using namespace std; // Hi ☻ int n,m; // towerscnt, mxjump vector<int> heights; const int M = 2e5+5; map<int,int> dp[M]; int solve(int index,int prev){ if(index >= n)return 0; auto it = dp[index].find(prev); if(it != dp[index].end())return it->second; if(heights[index]-prev > m){ // you need to lower this return dp[index][prev] = solve(index+1, prev+m)+1; }// you can get here // change this or don't return dp[index][prev] = min(solve(index+1,heights[index]),solve(index+1,prev+m)+1); // change this to max possible } int main(){ ios::sync_with_stdio(0);cin.tie(0); cin>>n>>m; heights.assign(n,0); for(auto &i:heights)cin>>i; cout<<solve(0,0) <<'\n'; // rabbit start at 0 height 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...