#include<bits/stdc++.h>
using namespace std;
typedef chrono::high_resolution_clock Clock_t;
typedef chrono::milliseconds Time_scale_t;
int main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
mt19937_64 random;
for(int k = 15; k <= 22; k++)
{
size_t n = 1 << k; multiset<int> x; vector<int> a(n);
for(int i = 0; i < n; i++)
x.insert(1+random()%100000);
auto start_time = Clock_t::now(); int j = 0;
// copying the multiset x to vector a
for(auto b:x)
a[j++] = b;
auto duration = Clock_t::now() - start_time;
assert( is_sorted(a.begin(),a.end()) );
auto elapsed_time = chrono::duration_cast<Time_scale_t>(duration).count();
cout << "pow(2," << k << ") = " << n << " items: " << elapsed_time << " msec\n";
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGNocm9ubzo6aGlnaF9yZXNvbHV0aW9uX2Nsb2NrIENsb2NrX3Q7CnR5cGVkZWYgY2hyb25vOjptaWxsaXNlY29uZHMgICAgIFRpbWVfc2NhbGVfdDsKIAppbnQgbWFpbigpIAp7Cglpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSwgY2luLnRpZShudWxscHRyKSwgY291dC50aWUobnVsbHB0cik7CgkKCW10MTk5MzdfNjQgcmFuZG9tOwoJCglmb3IoaW50IGsgPSAxNTsgayA8PSAyMjsgaysrKQoJewoJCXNpemVfdCBuID0gMSA8PCBrOyBtdWx0aXNldDxpbnQ+IHg7IHZlY3RvcjxpbnQ+IGEobik7IAoJCQoJCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgkJCXguaW5zZXJ0KDErcmFuZG9tKCklMTAwMDAwKTsKCQkKCQlhdXRvIHN0YXJ0X3RpbWUgID0gQ2xvY2tfdDo6bm93KCk7IGludCBqID0gMDsKCQkKCQkvLyBjb3B5aW5nIHRoZSBtdWx0aXNldCB4IHRvIHZlY3RvciBhIAoJCQoJCWZvcihhdXRvIGI6eCkKCQkJYVtqKytdID0gYjsKCQkKICAgIAlhdXRvIGR1cmF0aW9uID0gQ2xvY2tfdDo6bm93KCkgLSBzdGFydF90aW1lOwoKCQlhc3NlcnQoIGlzX3NvcnRlZChhLmJlZ2luKCksYS5lbmQoKSkgKTsKCQkKICAgIAlhdXRvIGVsYXBzZWRfdGltZSA9IGNocm9ubzo6ZHVyYXRpb25fY2FzdDxUaW1lX3NjYWxlX3Q+KGR1cmF0aW9uKS5jb3VudCgpOwoKICAgIAljb3V0IDw8ICJwb3coMiwiIDw8IGsgPDwgIikgPSAiIDw8IG4gIDw8ICIgaXRlbXM6ICIgPDwgZWxhcHNlZF90aW1lIDw8ICIgbXNlY1xuIjsKCX0KfQ==
pow(2,15) = 32768 items: 0 msec
pow(2,16) = 65536 items: 1 msec
pow(2,17) = 131072 items: 2 msec
pow(2,18) = 262144 items: 20 msec
pow(2,19) = 524288 items: 44 msec
pow(2,20) = 1048576 items: 95 msec
pow(2,21) = 2097152 items: 216 msec
pow(2,22) = 4194304 items: 433 msec