fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. bool longest(const std::vector<int>& lhs, const std::vector<int>& rhs)
  7. {
  8. return lhs.size() < rhs.size();
  9. }
  10.  
  11. int main() {
  12. std::vector<std::vector<int>> v = {{1,2,3}, {1,2,3,4}, {1,2}, {1},
  13. {1,2,3,4,5}, {1,2,3,4}};
  14.  
  15. auto it = std::max_element(v.begin(), v.end(), longest);
  16. cout << it->size();
  17. return 0;
  18. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
5