Pagini recente » Cod sursa (job #2569749) | Cod sursa (job #1623247) | Cod sursa (job #165612) | Cod sursa (job #1242314) | Cod sursa (job #167777)
Cod sursa(job #167777)
var e,c:array[1..1005] of integer;
v:array[1..1005] of real;
aux:real;
auxx,n,w,ww,i,j:integer;
cost:longint;
f:text;
begin
assign(f,'energii.in');reset(F);
readln(f,n);
readln(f,w);
for i:=1 to n do
begin
readln(f,e[i],c[i]);
v[i]:=(c[i]/e[i]);
end;
close(f);
for i:=1 to n-1 do
for j:=i+1 to n do
if v[i]>v[j] then
begin
aux:=v[i];
v[i]:=v[j];
v[j]:=aux;
auxx:=e[i];
e[i]:=e[j];
e[j]:=auxx;
auxx:=c[i];
c[i]:=c[j];
c[j]:=auxx;
end;
i:=1;
while w>0 do
begin
w:=w-e[i];
cost:=cost+c[i];
inc(i);
end;
assign(f,'energii.out');rewrite(f);
write(f,cost);
close(f);
end.