Mai intai trebuie sa te autentifici.
Cod sursa(job #514283)
| Utilizator | Data | 18 decembrie 2010 12:41:31 | |
|---|---|---|---|
| Problema | Energii | Scor | 5 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
const f='energii.in';h='energii.out';
var
n,w,i,j,min,s:longint;
c,e:array[1..1001] of longint;
g:array[1..10005] of longint;
begin
assign(input,f);reset(input);
assign(output,h);rewrite(output);
for i:=1 to n do readln(e[i],c[i]);
for i:=1 to 2*w do g[i]:=100000000;
for i:=1 to n do
for j:=2*w downto 1 do
if j>=e[i] then
if g[j-e[i]]+c[i]<g[j] then g[j]:=g[j-e[i]]+c[i];
min:=100000000;
for i:=2 to w*2 do
if min>g[i] then min:=g[i];
if min=100000000 then write('-1')
else write(min);
close(input);close(output);
end.