Cod sursa(job #478441)
| Utilizator | Data | 18 august 2010 17:36:38 | |
|---|---|---|---|
| Problema | Energii | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
program energii;
var i,j,n,g:integer; f,t:text;
castig,alege:array[0..1001]of integer;
gr,c:array[1..1001]of integer;
begin
assign(f,'energii.in');reset(f);
assign(t,'energii.out');rewrite(t);
readln(f,n);readln(f,g);
for i:=1 to n do readln(f,gr[i],c[i]);
for i:=1 to n do
for j:=1 to g do
if gr[i]<=j then
if c[i]+castig[j-gr[i]]>castig[j] then
castig[j]:=c[i]+castig[j-gr[i]];
write(t,castig[g]);
close(f);close(t);
end.