// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#define Debug(x...) _debug_print_format(#x, x);
std::ifstream terminal("/dev/tty");
#define PP cerr<<"\033[1;30mpause...\e[0m",terminal.ignore();
#else
#define debug(x...)
#define Debug(x...)
#define PP
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define FIND(a, x) ((find(a.begin(),a.end(),(x))!=a.end())?1:0)
#define cmin(x,...) x=min({(x),__VA_ARGS__})
#define cmax(x,...) x=max({(x),__VA_ARGS__})
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define NaN (int)(0x8b88e1d0595d51d1)
#define double long double
#define int long long
#define uint unsigned long long
#define MAXN 200010
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n; cin >> n;
vector<int> a(n+1), sum(n+1);
rep(i, 1, n+1) cin >> a[i], sum[i] = sum[i-1] + a[i];
vector<vector<int>> dp(n+1, vector<int>(n+1, INF)), m(n+1, vector<int>(n+1, -1));
rep(i, 1, n+1) dp[i][i] = 0, m[i][i] = i;
rep(len, 2, n+1) {
rep(i, 1, n+1) {
int l = i, r = i + len - 1;
if (r > n) break;
int ml = m[l][r-1], mr = m[l+1][r];
rep(k, ml, mr+1) {
if (k < l || k >= r) continue;
int v = sum[r] - sum[l-1] + dp[l][k] + dp[k+1][r];
if (v < dp[l][r]) dp[l][r] = v, m[l][r] = k;
}
}
}
cout << dp[1][n] << endl;
return 0;
}
Yo! Just signed up with taivn88 and I gotta say, registration was super easy. The promotions they offer are quite interesting too. Give it a shot and see what you think. More info here: taivn88
Looking for the right link? Linkbong8899 seems legit. Needed a quick and easy way to get where I needed to be to bet on my favourite matches this weekend! And this was it! linkbong8899
Downloaded the 333betapp the other day. Pretty smooth experience, I gotta say. No lag issues so far, and it’s convenient to have it right on my phone. Thumbs up from me!
The game variety is impressive and the graphics are top notch. I spend most of my free time here now. You guys should check out phabjili if you love variety.
I love how intuitive the navigation is. Even if you are new to this, you can find your way around easily. vm66game is simply fantastic.
I really enjoy the community vibe here. Everyone is friendly and the rewards are actually attainable. Big thanks to vn168fgame for the great time.
The winning streaks here are insane! I had a great run last night and the withdrawal was lightning fast. phww777 is the real deal.
I’ve been playing here for a few weeks now and the payouts are surprisingly fast. Definitely one of the smoother experiences I’ve had lately. Check out may888bet for a great time.