MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / solve

Function solve

Atcoder dp/N - Slimes.cpp:18–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16ll sum[3001][3001];//taking a dp
17
18ll solve(vector<int>& v, int i, int j)
19{
20 if(i == j)
21 return 0;
22 if(dp[i][j] != -1)
23 return dp[i][j];
24
25 ll minCost = inf;
26 for(int k = i; k < j; k++)
27 {
28 minCost = min(minCost, sum[i][j] + solve(v, i, k) + solve(v, k + 1, j));// solving for i to k and then i+1 to j
29 }
30 return dp[i][j] = minCost;
31}
32
33void preprocess(vector<int>& v, int n)
34{

Callers 1

mainFunction · 0.70

Calls 1

minFunction · 0.50

Tested by

no test coverage detected