субота, 9 січня 2016 р.

2014. Вместимость прямоугольников



program vmestimot;{Вывел результат  порядке возрастания вместимости, отследил
учёл одинаковую вместимость}
var
A:array [1..100,1..4] of integer;
P,V:array [1..100] of integer;
i,J,n,par:integer;
begin
Assign (input,'input.txt');
Reset (input);
read (n);
for i:=1 to N do
  begin
  for J:=1 to 4 do
   begin
    read (A[i,J]);
    //Write (A[i,J],' ');
   end;
  P[i]:=i;
  V[i]:=0;
  end;
for i:=1 to N-1 do
  begin
  for J:=i+1 to N do
    if (A[i,1]<=A[j,1]) and (A[i,2]<=A[j,2]) and (A[i,3]>=A[j,3]) and (A[i,4]>=A[j,4]) then V[i]:=V[i]+1;
  end;
for i:=1 to N-1 do
   for j:=I+1 to N do 
      if V[I]>V[j] then
        begin
          par:=V[j];
          V[j]:=V[I];
          V[i]:=par;
          par:=P[j];
          P[j]:=P[I];
          P[i]:=par;
        end;
       
 for i:=1 to N-1 do
   for j:=I+1 to N do        
    if (V[I]=V[j]) and (P[i]>P[j]) then
    begin
          par:=V[j];
          V[j]:=V[I];
          V[i]:=par;
          par:=P[j];
          P[j]:=P[I];
          P[i]:=par;
        end;
Assign (output,'output.txt');
Rewrite(output);
for i:=1 to N do
Writeln (P[i],' ',V[i]);
Close (input);
Close (output);

end.

Немає коментарів:

Дописати коментар