답안 #639596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639596 2022-09-10T17:19:29 Z luanaamorim K개의 묶음 (IZhO14_blocks) C++14
0 / 100
1 ms 212 KB
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <set>
#include <stack>
#include <bitset>
#define MAX (int) 2e3
#define ll long long
#define INF (ll)1e15

using namespace std;

ll n, m, arr[MAX], dp[MAX][101], maior[MAX][MAX];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			maior[i][j] = max(arr[j], maior[i][j-1]);

	for (int i = 0; i <= n+1; i++)
		for (int j = 0; j <= m; j++)
			dp[i][j] = INF;

	dp[n+1][0] = 0;

	for (int i = n; i >= 1; i--)
	{
		for (int k = 1; k <= m; k++)
		{
			for (int j = i; j <= n; j++)
				dp[i][k] = min(dp[i][k], dp[j+1][k-1] + maior[i][j]);
		}
	}

	cout << dp[1][m] << endl;
}	






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