Cod sursa(job #198334)
Utilizator | Data | 10 iulie 2008 13:54:01 | |
---|---|---|---|
Problema | Energii | Scor | 85 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
var g,w,i,j:longint;
e,c: longint;
v:array [1..100000] of longint;
begin
assign(input,'energii.in'); reset(input);
assign(output,'energii.out'); rewrite(output);
readln(g); readln(w);
for i:=1 to g do begin
readln(e,c);
for j:=2*w downto 1 do
if v[j]<>0 then
if (v[j+e]=0)or(v[j+e]>c+v[j]) then v[j+e]:=c+v[j];
if (v[e]=0) or (v[e]>c) then v[e]:=c;
end;
j:=w;
for i:=w to 100000 do
if (v[i]<v[j])and(v[i]>0) then j:=i;
write(v[j]);
close(input); close(output);
end.