fork download
  1. #include <algorithm>
  2. #include <vector>
  3. #include <cstdio>
  4.  
  5. int main() {
  6. std::vector<int> v = {6,5,4,3,2,1,1,2,1,1,1};
  7. std::nth_element(v.begin(), v.begin()+2, v.end());
  8. printf("%d\n", v[2]);
  9. return 0;
  10. }
Success #stdin #stdout 0s 3016KB
stdin
Standard input is empty
stdout
1