답안 #939113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939113 2024-03-06T05:50:15 Z ezzzay Stove (JOI18_stove) C++14
50 / 100
61 ms 94296 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=5e3+5;
int arr[N];
int dp[N][N];
signed main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<=k;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=INT_MAX;
        }
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int l=1;l<=k;l++){
            
            dp[l][i]=min(dp[l-1][i-1]+1,dp[l][i-1]+arr[i]-arr[i-1]);
            
        }
    }
    int ans=INT_MAX;
    for(int i=1;i<=k;i++)ans=min(ans,dp[i][n]);
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 2804 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 2804 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 10 ms 39004 KB Output is correct
13 Correct 30 ms 66404 KB Output is correct
14 Correct 59 ms 91864 KB Output is correct
15 Correct 61 ms 94296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 2804 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 10 ms 39004 KB Output is correct
13 Correct 30 ms 66404 KB Output is correct
14 Correct 59 ms 91864 KB Output is correct
15 Correct 61 ms 94296 KB Output is correct
16 Runtime error 6 ms 604 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -