Submission #792039

# Submission time Handle Problem Language Result Execution time Memory
792039 2023-07-24T14:13:06 Z 12345678 Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 516 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=5e3+5;
int n, m, a[nx], dp[nx][nx], ans=nx;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int i=1; i<nx; i++) dp[0][i]=nx;
    for (int i=1; i<=n; i++)
    {
        for (int j=0; j<nx; j++) dp[i][j]=dp[i-1][j]+1;
        for (int j=max(0, a[i]-m); j<nx; j++) dp[i][a[i]]=min(dp[i][a[i]], dp[i-1][j]);
    }
    for (int i=0; i<nx; i++) ans=min(ans, dp[n][i]);
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 516 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Incorrect 1 ms 468 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 516 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Incorrect 1 ms 468 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 516 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Incorrect 1 ms 468 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 516 KB Output is correct
5 Correct 1 ms 452 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Incorrect 1 ms 468 KB Output isn't correct
13 Halted 0 ms 0 KB -