Home > Back-end >  Advice on how to use vector to realize several tower
Advice on how to use vector to realize several tower

Time:04-01

/* because learning STL library recently, so I want to use the vector instead of a two-dimensional array to realize the number of tower problems 
Enter the following
5
5
8 3
12 July 16
4 10 November 6
9 5 3 9 4
Output the following
44

Input can directly out of the normal input and output don't come out program leaders help see QAQ (I know that a two-dimensional array can be achieved, just want to know the vector can be used to solve the problem)
*/
# include & lt; Bits/stdc++. H>
using namespace std;

Int main ()
{
Int n, temp;
Cin> n;
Vector F (n + 1);
Vector Dp (n + 1);
Vector V (n + 1);
for(int i=1; i<=n; I++) {
V.c Lear ();
For (int j=1; j<=I; J++) {
Cin> Temp.
Valerie plame ush_back (temp);
}
F.p ush_back (v);
}
For (int j=1; j<=n; J++) {
Dp [n] [j]=f [n] [j];
}
For (int I=n - 1; I>=1; I++) {
For (int j=1; j<=I; J++)
{

Dp [I] [j]=Max (dp [j], [I + 1] dp + 1] [I [j + 1) + f [I] [j];
}
}
coutreturn 0;
}
  • Related