#include #include using namespace std; const int lim = 100000; bitset now; int f(int y) { int l = y-1, r = lim+1; while (l + 1 < r){ int m = (l + r) / 2; if ((now >> m).count() >= 1) l = m; else r = m; } return l; } int main() { int N; scanf ("%d",&N); while (N--){ int x,y; scanf ("%d %d",&x,&y); int z = f(y); if (z >= y) now[z] = 0; auto v = ((now << (lim - y)) >> (lim - y + x)) << x; now ^= v; now ^= (v << 1); now[x] = 1; } printf ("%d\n",now.count()); return 0; }