Cod sursa(job #109309)

Utilizator zuzulicatilimpea razvan nicolae zuzulica Data 25 noiembrie 2007 10:08:52
Problema Teren Scor 0
Compilator fpc Status done
Runda preONI 2008, Runda 1, Clasa a 9-a Marime 0.81 kb
program p1;
var a:array[1..100,1..100] of integer;
    n,m,s,max,i,j,x,i1,j1,i2,j2:integer;
    fin,fout:text;
    h:string;
    begin
    assign(fin,'teren.in');
    reset(fin);
    read(fin,n,m,x);
    for i:=1 to n do
    begin
    for j:=1 to m do
    read(fin,a[i,j]);
    readln(fin);
    end;
    close(fin);
    for i:=1 to n do
    begin
    for j:=1 to m do
    begin
    for i1:=1 to n-i+1 do
    begin
    for j1:=1 to m-j+1 do
    begin
    s:=0;
    for i2:=i1 to i1-1 do
    begin
    for j2:=j1 to j1-1 do
    begin
    if a[i2,j2]=1 then
    s:=s+1;
    end;
    end;
    if s<=x then
    if i*j>max then
    max:=i*J;
    end;
    end;
    end;
    end;
    assign(fout,'teren.out');
    rewrite(fout);
    str(max,h);
    write(fout,h);
    close(fout);
    end.