fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(void) {
  4. ios_base::sync_with_stdio(false);cin.tie(NULL);
  5.  
  6. const int N = 1LL<<20,inf = 1e9;
  7. vector<int> a(N);
  8. iota(a.begin(),a.end(),0);
  9. a[0]=inf;
  10. int cnt = 0;
  11. const auto cmp = [&](const int &x,const int &y)->bool{
  12. if(x==inf||y==inf)
  13. cnt++;
  14. return x<y;
  15. };
  16. stable_sort(a.begin(),a.end(),cmp);
  17. cout<<"N - "<<N<<std::endl;
  18. cout<<"std::stable_sort worstcase - "<<cnt<<std::endl;
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.04s 9904KB
stdin
Standard input is empty
stdout
N - 1048576
std::stable_sort worstcase - 1048575