이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
// Hi ☻
int n,m; // towerscnt, mxjump
vector<int> heights;
const int M = 5005;
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 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... |