Bomber Mans wants to bomb an Array.
problem DescriptionGiven an array and some positions where to plant the bombs, you have to print the total Maximum Impact.
Each Bomb have some left destruction capabilityLAnd some right destruction capabilityRWhich means if a bomb is dropped atITh location It'll destroyLBlocks on the left andRBlocks on the right.
Number of Blocks destroyed by a bomb isL+R+1
Total Impact are calculated as product of number of blocks destroyed by each bomb.
IfITh bomb destroysXi Blocks ThenTOTalImpact=X1∗x2∗. . . Xm
Given the bombing locations in the array, print the Maximum total Impact such that every block of the array is destoryed E Xactly once (i.e it is effected by only one bomb).
# # Rules of bombing
1. Bomber man wants to plant a bomb in every bombing location.
2. Bomber man wants to destroy each block with only once.
3. Bomber man wants to destroy every block.
InputThere is multi test cases denote by a integerT(t≤) In the first line.
First line, integersN and M which are the number of locations and number of bombing locations respectivly.
Second line contains M distinct integers specifying the bombing Locations.
1 <= N <= 2000
1 <= M <= N
OutputAs Maximum total impact can is very large print the floor (1000000 * LOG2 (Maximum total impact)).
Hint:
Sample 1:
Sample 2:
Sample Input210 20 910 30 4 8
Sample Output46438565169925
Test instructions
Give a length ofNN the one-dimensional lattice and the location of some bombs, please calculate the "Maximum total damage index". Each bomb has a destructive force to the left and to the right, if a bomb is destructive to the left and right, respectively.LL andRR, then the bomb will blow upL + R + 1L+R+1 lattices (leftLL, the bomb's in the grid, right.RR). The damage index is calculated as the product of the number of squares destroyed by all bombs. Assuming that sectionII blew up a bomb.X_iX?I?? Grid, then the total damage index isX_1 * x_2 * .... X_mX?1?? ∗x ? 2 ?? ∗.x ? m ??。 Now tell you the location of each bomb, you need to calculate the maximum total damage index, note: Each lattice is allowed to be bombed only once.
Exercises
Dp
Set F[I][J] Indicates the maximum destructive power of the first I bomb to J
We're going to enumerate the current bombs and update the answers in the context of the f[i][k.
#pragmaComment (linker, "/stack:10240000,10240000")#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>#include<iostream>Const intN = 2e3+Ten, M = 1e6+ -;using namespaceStd;typedefLong Longll;intt,n,m;DoubleF[n][n];inta[n],x;intMain () {scanf ("%d",&T); while(t--) {scanf ("%d%d",&m,&N); for(intI=1; i<=n;i++) scanf ("%d", &x), a[i] = x +1; Sort (a+1, a+n+1); Memset (F,0,sizeof(f)); f[0][0] =0.0; a[0] =0, a[n+1] = m+1; for(intI=1; i<=n;i++) { for(intj=a[i];j<a[i+1];j++) { for(intk=a[i-1]+1; k<=a[i];k++) {F[i][j]= Max (F[i][j], f[i-1][k-1] + log (j-k+1)/log (2)); }}} printf ("%lld\n", (ll) floor (1000000*f[n][m])); } return 0;}
HDU 5653 Bomber man wants to bomb an Array. DP