Pagini recente » Cod sursa (job #1256869) | Cod sursa (job #987049) | Cod sursa (job #1254927) | Diferente pentru teorema-chineza-a-resturilor intre reviziile 49 si 48 | Cod sursa (job #123797)
Cod sursa(job #123797)
var n,m,i,j,k,s,max,sum,q,p:longint;
v,x:array[0..300,0..300] of longint;
begin
assign(input,'teren.in');reset(input);
assign(output,'teren.out');rewrite(output);
readln(n,m,s);
for i:=1 to n do
for j:=1 to m do
read(v[i,j]);
for i:=1 to m do
for j:=1 to n do
x[j,i]:=x[j-1,i]+v[j,i];
for i:=1 to n do
for j:=i to n do
begin
//calculez arie maxima ce se poate obtine intre liniile
//i si j
k:=1;
p:=0;q:=0;
sum:=0;
while (q<=m) do
begin
while (sum<=s)and(q<=m) do
begin
inc(q);
sum:=sum+x[j,q]-x[i-1,q];
end;
dec(q);
if (q-p)*(j-i+1)>max then
max:=(q-p)*(j-i+1);
while (sum>s)and(p<=m) do
begin
inc(p);
sum:=sum-(x[j,p]-x[i-1,p]);
end;
inc(q);
end;
end;
writeln(max);
close(input);close(output);
end.