답안 #996460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996460 2024-06-10T16:02:24 Z overwatch9 Stove (JOI18_stove) C++17
20 / 100
1000 ms 133804 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int n, k;
vector <int> t;
const int maxn = 5000 + 1;
ll dp[maxn][maxn];
bool ready[maxn][maxn];
ll solve(int i, int left) {
    if (i > n)
        return 0;
    if (left <= 0 && i <= n)
        return 1e18;
    if (ready[i][left])
        return dp[i][left];
    ll ans = 1e18;
    for (int j = i; j <= n; j++) 
        ans = min(ans, solve(j+1, left - 1) + t[j] - t[i] + 1);
    ready[i][left] = true;
    dp[i][left] = ans;
    return ans;
}
int main() {
    cin >> n >> k;
    t.resize(n+1);
    for (int i = 1; i <= n; i++)
        cin >> t[i];
    cout << solve(1, k) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2496 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2496 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 236 ms 133804 KB Output is correct
11 Execution timed out 1058 ms 131416 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2496 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 236 ms 133804 KB Output is correct
11 Execution timed out 1058 ms 131416 KB Time limit exceeded
12 Halted 0 ms 0 KB -