#include<stdio.h>
int main()
{
int x[100000][2];
int i,t,save,c;
int q=0,sum1,sum2=0;
int rat;
while(t--)
{scanf("%d%d",&x
[q
][0],&x
[q
][1]);
sum2+=x[q][1];
save=x[q][0];
rat=x[q][1];
c=q;
for(i=0;i<q;i++)
{
if(x[i][0]>save)
{while(c>i)
{x[c][0]=x[c-1][0];
x[c][1]=x[--c][1];
}
x[i][0]=save;
x[i][1]=rat;
}
}
sum1=0;
for(i=0;i<=q/2;i++)
sum1+=x[i][1];
if(2*sum1>sum2)
else
q++;
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKCkKewppbnQgeFsxMDAwMDBdWzJdOwppbnQgaSx0LHNhdmUsYzsKaW50IHE9MCxzdW0xLHN1bTI9MDsKaW50IHJhdDsKc2NhbmYoIiVkIiwmdCk7CndoaWxlKHQtLSkKe3NjYW5mKCIlZCVkIiwmeFtxXVswXSwmeFtxXVsxXSk7CgogICAgc3VtMis9eFtxXVsxXTsKICAgIHNhdmU9eFtxXVswXTsKICAgIHJhdD14W3FdWzFdOwogICAgYz1xOwogICAgZm9yKGk9MDtpPHE7aSsrKQogICAgewogICAgaWYoeFtpXVswXT5zYXZlKQogICAgICAgIHt3aGlsZShjPmkpCiAgICAgICAgICAgIHt4W2NdWzBdPXhbYy0xXVswXTsKICAgICAgICAgICAgeFtjXVsxXT14Wy0tY11bMV07CiAgICAgICAgICAgIH0KICAgICAgICB4W2ldWzBdPXNhdmU7CiAgICAgICAgeFtpXVsxXT1yYXQ7CiAgICAgICAgfQogICAgfQogICAgc3VtMT0wOwogICAgZm9yKGk9MDtpPD1xLzI7aSsrKQogICAgc3VtMSs9eFtpXVsxXTsKICAgIGlmKDIqc3VtMT5zdW0yKQogICAgcHJpbnRmKCIlZFxuIiwyKnN1bTEtc3VtMik7CiAgICBlbHNlCiAgICBwcmludGYoIiVkXG4iLHN1bTItMipzdW0xKTsKICAgIHErKzsKfQpyZXR1cm4gMDsKfQoK