Advertisement
Guest User

Untitled

a guest
Oct 12th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. int main()
  6. {
  7.     std::vector<std::vector<std::size_t>> t
  8.     {
  9.         {75},
  10.         {95, 64},
  11.         {17, 47, 82},
  12.         {18, 35, 87, 10},
  13.         {20,  4, 82, 47, 65},
  14.         {19,  1, 23, 75,  3, 34},
  15.         {88,  2, 77, 73,  7, 63, 67},
  16.         {99, 65,  4, 28,  6, 16, 70, 92},
  17.         {41, 41, 26, 56, 83, 40, 80, 70, 33},
  18.         {41, 48, 72, 33, 47, 32, 37, 16, 94, 29},
  19.         {53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14},
  20.         {70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57},
  21.         {91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48},
  22.         {63, 66,  4, 68, 89, 53, 67, 30, 73, 16, 69, 87, 40, 31},
  23.         { 4, 62, 98, 27, 23,  9, 70, 98, 73, 93, 38, 53, 60,  4, 23}
  24.     };
  25.  
  26.     for(auto l = t.rbegin() + 1; l != t.rend(); ++l)
  27.     {
  28.         for(std::size_t i = 0; i < l->size(); ++i)
  29.         {
  30.             l->at(i) += std::max((l - 1)->at(i), (l - 1)->at(i + 1));
  31.         }
  32.     }
  33.  
  34.     std::cout << t.at(0).at(0) << std::endl;
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement