fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <numeric>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. vector<int> foo(9);
  11. const vector<int> v = { 2, 9, 3, 6, 5, 8, 8, 8, 8, 7, 2, 2, 8, 1, 4 };
  12.  
  13. generate(begin(foo), end(foo), [i = int{ 1 }]() mutable {
  14. auto result = i;
  15. i *= 10;
  16. return result; });
  17.  
  18. auto maximum = 0;
  19.  
  20. for (auto it = prev(rend(v), foo.size() + 1); it != rbegin(v); advance(it, -1)) {
  21. maximum = max<int>(inner_product(cbegin(foo), cend(foo), it, 0), maximum);
  22. }
  23. maximum = max<int>(inner_product(cbegin(foo), cend(foo), rbegin(v), 0), maximum);
  24.  
  25. cout << maximum;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
936588887