답안 #796966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796966 2023-07-29T01:37:33 Z 12345678 Rabbit Carrot (LMIO19_triusis) C++17
35 / 100
111 ms 98488 KB
#include <bits/stdc++.h>

using namespace std;

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

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++)
    {
        int mn=1e9;
        vector<int> v(nx);
        for (int j=nx-1; j>=0; j--) mn=min(mn, dp[i-1][j]), v[j]=mn;
        for (int j=0; j<nx; j++) dp[i][j]=v[max(0, j-m)]+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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 536 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 Correct 4 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 536 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 Correct 4 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 448 KB Output is correct
15 Correct 1 ms 456 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 456 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 85 ms 79604 KB Output is correct
21 Correct 106 ms 98224 KB Output is correct
22 Correct 92 ms 98336 KB Output is correct
23 Correct 104 ms 98244 KB Output is correct
24 Correct 111 ms 98240 KB Output is correct
25 Correct 103 ms 98488 KB Output is correct
26 Correct 94 ms 98280 KB Output is correct
27 Correct 94 ms 98308 KB Output is correct
28 Correct 95 ms 98332 KB Output is correct
29 Correct 107 ms 98224 KB Output is correct
30 Correct 109 ms 98336 KB Output is correct
31 Correct 97 ms 98304 KB Output is correct
32 Correct 101 ms 98252 KB Output is correct
33 Correct 100 ms 98332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 85 ms 79604 KB Output is correct
5 Correct 106 ms 98224 KB Output is correct
6 Correct 92 ms 98336 KB Output is correct
7 Correct 104 ms 98244 KB Output is correct
8 Correct 111 ms 98240 KB Output is correct
9 Correct 103 ms 98488 KB Output is correct
10 Correct 94 ms 98280 KB Output is correct
11 Correct 94 ms 98308 KB Output is correct
12 Correct 95 ms 98332 KB Output is correct
13 Correct 107 ms 98224 KB Output is correct
14 Correct 109 ms 98336 KB Output is correct
15 Correct 97 ms 98304 KB Output is correct
16 Correct 101 ms 98252 KB Output is correct
17 Correct 100 ms 98332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 536 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 4 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 448 KB Output is correct
32 Correct 1 ms 456 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 81 ms 98240 KB Output is correct
35 Incorrect 85 ms 98368 KB Output isn't correct
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 98240 KB Output is correct
2 Incorrect 85 ms 98368 KB Output isn't correct
3 Halted 0 ms 0 KB -