-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixtures_BottomUp.cpp
More file actions
58 lines (54 loc) · 1.05 KB
/
Copy pathmixtures_BottomUp.cpp
File metadata and controls
58 lines (54 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;
vector<int> color = {40, 60, 20};
int sum(int x, int y)
{
int temp = 0;
int i = x;
while (i <= y)
{
temp += color[i];
temp %= 100;
i++;
}
return temp;
}
int32_t main()
{
int n = 3;
vector<vector<int> > dp(n+1, vector<int>(n+1, 0));
for (int j = 1; j < n; j++)
{
for (int i = j - 1; i >= 0; i--)
{
dp[i][j] = INT_MAX;
for (int k = i; k <= j; k++)
{
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum(i, k) * sum(k + 1, j));
}
}
}
cout << dp[0][n - 1] << endl;
}