답안 #657904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657904 2022-11-11T16:39:24 Z kusssso Stove (JOI18_stove) C++14
50 / 100
438 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;
const ll inf = 1e18;

int n, k;
ll t[N], dp[5005][5005];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> t[i];
    for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = inf;
    dp[0][0] = 0;
    for (int z = 1; z <= k; z++) {
        ll min_dp = inf;
        for (int i = 1; i <= n; i++) {
            min_dp = min(min_dp, dp[i - 1][z - 1] - t[i]);
            dp[i][z] = min(dp[i][z], min_dp + t[i] + 1);
        }
    }
    cout << dp[n][k];
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 39 ms 82892 KB Output is correct
11 Correct 37 ms 82964 KB Output is correct
12 Correct 61 ms 82928 KB Output is correct
13 Correct 91 ms 82932 KB Output is correct
14 Correct 122 ms 82928 KB Output is correct
15 Correct 125 ms 82932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 39 ms 82892 KB Output is correct
11 Correct 37 ms 82964 KB Output is correct
12 Correct 61 ms 82928 KB Output is correct
13 Correct 91 ms 82932 KB Output is correct
14 Correct 122 ms 82928 KB Output is correct
15 Correct 125 ms 82932 KB Output is correct
16 Runtime error 438 ms 262144 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -