/**
* Sergey Kopeliovich (burunduk30@gmail.com)
*
* Обычная версия: 0.69 = new(0.12), pushback(0.44), delete(0.13)
* Перегруженный new: 0.18 = new(0.12), pushback(0.06), delete(0.00)
*
* Оптимизация в 4 раза ;)
*/
#define FAST_ALLOC 1
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
// --------------------------------------------------------------
#if FAST_ALLOC
const int MAX_MEM = 3e8;
int mpos = 0;
char mem[MAX_MEM];
void * operator new (size_t n) {
assert((mpos += n) <= MAX_MEM);
return (void *)(mem + mpos - n);
}
void operator delete (void *) { } // must have!
void operator delete (void *, size_t) { } // must have!
#endif /* FAST_ALLOC */
// --------------------------------------------------------------
const int N = 1e7;
void timeS(const char *s = 0) {
static double start = 0;
fprintf(stderr, "%.2f : %s\n", 1. * (clock() - start) / CLOCKS_PER_SEC, s ? s : "");
start = clock();
}
int main() {
{
vector<vector<int>> a(N);
timeS("new");
forn(i, N) a[i].push_back(i);
timeS("push_back");
}
timeS("delete");
}