Submission #639650

# Submission time Handle Problem Language Result Execution time Memory
639650 2022-09-10T19:15:16 Z Pietra Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
96 ms 262144 KB
// pra cada cara a gnt sabe o intervalo q ele pode precisar
// v[i] - m (sair dele p esse) ou
// dp[i][s] -> min qtd de descidas q eu preciso
// p com s subidas chegar em i
// tem um intervalo p cada cara mas isso depende dos anteriores
// dp[i][alt] = min de ops q eu preciso fzr para que esteja ok
// chegar em i com o ultimo tendo altura alt
#include<bits/stdc++.h>
using namespace std ;

const int maxn = 5e3 + 5 ;
const int maxx = 20 ;

int n, m, v[maxn], dp[maxn][10*maxn], mx ;

int solve(int i, int alt){
   // cout << i << " " << alt << "\n" ;
    if(i > n) return 0 ;
    if(dp[i][alt] != -1) return dp[i][alt] ;
    int ans = maxn ;
    int op1 = alt + m, op2 = v[i] ;
    ans = min({ans, solve(i+1, op1) + 1, solve(i+1, 0) + 1}) ;
    if(v[i] <= alt + m) ans = min(ans, solve(i+1, op2)) ;
    return dp[i][alt] = ans ;
}

int main(){

    ios_base::sync_with_stdio(false) ; cin.tie(NULL) ;

    cin >> n >> m ;

    for(int i = 1 ; i <= n ; i++) cin >> v[i] ;

    for(int i = 1 ; i <= n ; i++) mx = max(mx, v[i]) ;

    memset(dp, -1, sizeof dp) ;

    cout << solve(1, 0) << "\n" ;

}
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -