Submission #333295

# Submission time Handle Problem Language Result Execution time Memory
333295 2020-12-05T09:53:26 Z AmineTrabelsi Rabbit Carrot (LMIO19_triusis) C++14
14 / 100
1000 ms 86856 KB
#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 time Memory Grader output
1 Correct 7 ms 9712 KB Output is correct
2 Correct 7 ms 9708 KB Output is correct
3 Correct 7 ms 9708 KB Output is correct
4 Correct 7 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 7 ms 9708 KB Output is correct
8 Correct 8 ms 9708 KB Output is correct
9 Correct 7 ms 9708 KB Output is correct
10 Correct 7 ms 9708 KB Output is correct
11 Correct 7 ms 9708 KB Output is correct
12 Correct 7 ms 9708 KB Output is correct
13 Correct 7 ms 9708 KB Output is correct
14 Correct 7 ms 9728 KB Output is correct
15 Correct 7 ms 9708 KB Output is correct
16 Correct 7 ms 9708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9708 KB Output is correct
2 Correct 8 ms 9708 KB Output is correct
3 Correct 8 ms 9708 KB Output is correct
4 Execution timed out 1089 ms 69100 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10476 KB Output is correct
2 Correct 24 ms 16108 KB Output is correct
3 Correct 24 ms 16364 KB Output is correct
4 Execution timed out 1103 ms 86856 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 10476 KB Output is correct
2 Correct 24 ms 16108 KB Output is correct
3 Correct 24 ms 16364 KB Output is correct
4 Execution timed out 1103 ms 86856 KB Time limit exceeded
5 Halted 0 ms 0 KB -