답안 #413814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
413814 2021-05-29T14:32:23 Z illyakr Stove (JOI18_stove) C++14
50 / 100
136 ms 262148 KB
#include <bits/stdc++.h>

using namespace std;

int n, k;
vector<vector<int> > dp;
int pref = -1;
int main()
{
    cin >> n >> k;
    dp.resize(n + 2, vector<int>(k + 2, 1010101010));
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i == 1) {
            dp[i][1] = 1;
        } else {
            for (int j = 1; j <= k; j++) {
                dp[i][j] = dp[i - 1][j] + (a - pref);
                if (j > 1)dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);
            }
        }
        pref = a;
    }
    int mn = 1010101010;
    for (int i = 1; i <= k; i++) {
        mn = min(mn, dp[n][i]);
//        cout << setw(2) << i << "  " << dp[n][i] << endl;
    }
    cout << mn;
}
/**
10 5
1
2
5
6
8
11
13
15
16
20

3 2
1 3 6
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 4 ms 1540 KB Output is correct
12 Correct 12 ms 12196 KB Output is correct
13 Correct 22 ms 23856 KB Output is correct
14 Correct 37 ms 34472 KB Output is correct
15 Correct 33 ms 35532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 4 ms 1540 KB Output is correct
12 Correct 12 ms 12196 KB Output is correct
13 Correct 22 ms 23856 KB Output is correct
14 Correct 37 ms 34472 KB Output is correct
15 Correct 33 ms 35532 KB Output is correct
16 Correct 56 ms 9776 KB Output is correct
17 Correct 88 ms 44260 KB Output is correct
18 Runtime error 136 ms 262148 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -