답안 #533716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533716 2022-03-07T03:54:59 Z zxcvbnm K개의 묶음 (IZhO14_blocks) C++14
0 / 100
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int nax = 105;
constexpr int INF = 1e9 + 5;
int dp[nax][nax];
int mx[nax][nax];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    assert(n < nax);

    vector<int> a(n);
    for(int& i : a) {
        cin >> i;
    }
    for(int i = 0; i < n; i++) {
        priority_queue<int> curr;
        for(int j = 0; j < n; j++) {
            curr.push(a[j]);
            mx[i][j] = curr.top();
        }
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            dp[i][j] = INF;
//            cout << i << " " << j << ": " << mx[i][j] << "\n";
        }
    }

    for(int i = 0; i < n; i++) {
        dp[i][0] = 0;
        dp[i][1] = mx[0][i];
    }

    for(int splits = 2; splits <= k; splits++) {
        for(int i = splits-1; i < n; i++) {
            for(int j = 0; j < i; j++) {
                dp[i][splits] = min(dp[i][splits], dp[j][splits-1] + mx[j+1][i]);
//                cout << i << " " << splits << ": " << dp[j][splits-1] << " " << mx[i+1][j] << "\n";
            }
//            cout << i << " " << splits << ": " << dp[i][splits] << "\n";
        }
    }

    cout << dp[n-1][k] << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -