#include #include using namespace std; const int maxs = 200; int c,g[1010][maxs*2+1],s[1010],p[1010],r[100010]; void just() { int n = 0; for (int i=0;iv;j--) g[i][j] = g[i][j-1]; s[i]++; } void ins(int x) { if (c == 0){ g[0][0] = x; s[0] = 1; p[0] = 0; c = 1; return; } for (int i=0;i g[i][v] + p[i]) v++; mak(i,v); g[i][v] = x - p[i]; if (s[i] == maxs*2) just(); break; } } } int main() { int N; scanf ("%d",&N); while (N--){ int x,y; scanf ("%d %d",&x,&y); rem(y); add(x,y); ins(x); } int ans = 0; for (int i=0;i