답안 #996479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996479 2024-06-10T17:06:40 Z overwatch9 Stove (JOI18_stove) C++17
50 / 100
1000 ms 262144 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;
int N, K;
vector <int> t;
const int maxn = 5000 + 1;
ll dp[maxn][maxn];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> K;
    t.resize(N+1);
    for (int i = 1; i <= N; i++)
        cin >> t[i];
    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        fill(dp[i]+1, dp[i] + maxn, 1e18);
    }
    dp[0][0] = 0;
    set <ll> s;
    for (int j = 1; j <= K; j++) {
        for (int i = 1; i <= N; i++) {
            if (i == 1) {
                dp[i][j] = 1;
                continue;
            } else if (j == 1) {
                dp[i][j] = t[i] - t[1] + 1;
                continue;
            } else
                s.insert(dp[i-1][j-1] - t[i] + 1);
            dp[i][j] = *s.begin() + t[i];
        }
        s.clear();
    }
    for (int i = 1; i <= K; i++)
        ans = min(ans, dp[N][i]);
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 0 ms 2652 KB Output is correct
5 Correct 0 ms 2652 KB Output is correct
6 Correct 0 ms 2652 KB Output is correct
7 Correct 0 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 0 ms 2652 KB Output is correct
5 Correct 0 ms 2652 KB Output is correct
6 Correct 0 ms 2652 KB Output is correct
7 Correct 0 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 20 ms 119644 KB Output is correct
11 Correct 43 ms 119644 KB Output is correct
12 Correct 271 ms 119640 KB Output is correct
13 Correct 426 ms 119808 KB Output is correct
14 Correct 634 ms 119632 KB Output is correct
15 Correct 617 ms 119640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 0 ms 2652 KB Output is correct
5 Correct 0 ms 2652 KB Output is correct
6 Correct 0 ms 2652 KB Output is correct
7 Correct 0 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 20 ms 119644 KB Output is correct
11 Correct 43 ms 119644 KB Output is correct
12 Correct 271 ms 119640 KB Output is correct
13 Correct 426 ms 119808 KB Output is correct
14 Correct 634 ms 119632 KB Output is correct
15 Correct 617 ms 119640 KB Output is correct
16 Execution timed out 2272 ms 262144 KB Time limit exceeded
17 Halted 0 ms 0 KB -