답안 #856420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856420 2023-10-03T12:40:18 Z __Davit__ K개의 묶음 (IZhO14_blocks) C++17
0 / 100
0 ms 348 KB
//#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
#include <fstream>

#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define vr(v) v.begin(),v.end()
#define rv(v) v.rbegin(),v.rend()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Davit cout.tie(NULL);
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	vector<vector<int>> dp(n, vector<int>(k+5,1e9));
	int mx = v[0];
	for (int i = 0; i < n; i++) {
		mx = max(mx, v[i]);
		dp[i][0] = mx;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			int X = -1e9;
			for (int l = i-1; l >= 0; l--) {
				X = max(X, v[l]);
				dp[i][j] = min(dp[i][j], dp[l][j-1] + X);
			}
		}
	}
	cout << dp[n - 1][k] << endl;
	
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -