Pagini recente » Cod sursa (job #2558999) | Cod sursa (job #1483678) | Cod sursa (job #2603281) | Cod sursa (job #1094521) | Cod sursa (job #264309)
Cod sursa(job #264309)
var g,w,min,a,b,i,c,s,j,x,ct,y:integer;
f,e:text;
BEGIN
assign(f,'energii.in');reset(f);assign(e,'energii.out');rewrite(e);
read(f,g);read(f,w);min:=-1;c:=10001;j:=0;s:=0; ct:=0;
for i:=1 to g do
BEGIN
readln(f,a,b);
if a>=w then
begin
if (a>=w) and (b<c) then
begin
c:=b;
min:=a;
end;
end;
if a<w then
BEGIN
x:=a;y:=b;
for j:=i+1 to g do
begin
readln(f,a,b);
if a<w then
begin
s:=s+a;
ct:=ct+b;
end;
end;
s:=s+x;
ct:=ct+y;
END; reset(f);
END;
if min>=w then write (e,c) else write(e,-1);
close(f);close(e);
END.