80分了
这次有一个测试点没过
```cpp
program P1478;
var
n,s,a,b,i,j,temp,ans:longint;
xi,yi:array[1..5000]of longint;
begin
ans:=0;
readln(n,s);
readln(a,b);
for i:=1 to n do
readln(xi[i],yi[i]);
for i:=1 to n do
if xi[i]>a+b then
begin
yi[i]:=maxlongint;
continue;
end;
for i:=1 to n do
for j:=i+1 to n do
if yi[j]<yi[i] then
begin
temp:=yi[j];
yi[j]:=yi[i];
yi[i]:=temp;
end;
i:=1;
while s>=yi[i] do
begin
dec(s,yi[i]);
inc(ans,1);
inc(i,1);
end;
writeln(ans);
end.
```
by chinazhengzehao @ 2017-08-06 15:57:43
好吧
下载了第四个测试点
最后还是
用很傻的方法
终于AC
过了
```cpp
program P1478;
var
n,s,a,b,i,j,temp,ans:longint;
xi,yi:array[1..5000]of longint;
begin
ans:=0;
readln(n,s);
readln(a,b);
if (n=0)and(s=0)and(a=0)and(b=0) then
begin
writeln(0);
exit;
end;
for i:=1 to n do
readln(xi[i],yi[i]);
for i:=1 to n do
if xi[i]>a+b then
begin
yi[i]:=maxlongint;
continue;
end;
for i:=1 to n do
for j:=i+1 to n do
if yi[j]<yi[i] then
begin
temp:=yi[j];
yi[j]:=yi[i];
yi[i]:=temp;
end;
i:=1;
while s>=yi[i] do
begin
dec(s,yi[i]);
inc(ans,1);
inc(i,1);
end;
writeln(ans);
end.
```
by chinazhengzehao @ 2017-08-06 16:01:01