Sometimes, if you do not understand the question, you will not be able to answer questions (this is not nonsense ...)
This question is really disgusting. It is very simple and hard to understand !!
Question:
This question is indeed a bit difficult to understand. At least for me, this is the case. So I went to someone else's blog and read the meaning of the question, which is summarized as follows:
A series with the length of n is given, which is divided into several segments with the minimum requirement. Among them, ai is the first in each series, and bi is the length of each segment, l is to divide the series into l segments.
Example: n = 7, A = {1 2 4 4 5 4 3}, divide it into 1 2 4 | 4 5 | 4 | 3, the space used is 1*2 ^ 3 + 4*2 ^ 2 + 4*2 ^ 1 + 3*2 ^ 1 = 38, if it is divided into 1 2 | 4 4 5 | 4 3, the space used is 1*2 ^ 2 + 4*2 ^ 3 + 4*2 ^ 2 = 52, larger than 38.
#include
#include
#include
#include
#include
#include
#include
#include
#include using namespace std;#define maxn 110#define LL __int64LL mp[maxn][maxn];LL a[maxn];LL dos(LL x,LL y){ if(mp[x][y])return mp[x][y]; LL minn=a[x]; for(LL i=x;i<=y;i++)minn=minn*2; if(y-x+1>20) { minn=0; for(LL i=x;i<=y;i++)minn+=a[i]*2; } for(LL i=x;i