about summary refs log tree commit diff
path: root/others/volume1/071.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-19 11:37:07 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-19 11:37:07 +0700
commita53c4128c29f98b5fdfd9b0e13a3bbe094d975ec (patch)
tree77351187cc721bb535ffb3ff140e1355276ba8c2 /others/volume1/071.pas
parentfed71ad5b9c7e3524931b939ec369a559cf2b0b9 (diff)
downloadcp-a53c4128c29f98b5fdfd9b0e13a3bbe094d975ec.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/071.pas')
-rw-r--r--others/volume1/071.pas42
1 files changed, 42 insertions, 0 deletions
diff --git a/others/volume1/071.pas b/others/volume1/071.pas
new file mode 100644
index 0000000..59191da
--- /dev/null
+++ b/others/volume1/071.pas
@@ -0,0 +1,42 @@
+{$mode objfpc}
+uses math, clib;
+
+var
+  n, m, i, j: int16;
+  (* For math compatibility *)
+  a: array of array of integer;
+  res: array of integer;
+  (* For clib compatibility *)
+  rowmin: array of int64;
+  colmax: int64;
+
+begin
+  readln(n, m);
+  setlength(a, n);
+  setlength(rowmin, n);
+  for i := 0 to n - 1 do
+    begin
+      setlength(a[i], m);
+      for j := 0 to m - 1 do
+        read(a[i][j]);
+      rowmin[i] := minvalue(a[i])
+    end;
+  qsort(rowmin);
+  setlength(res, 0);
+  for j := 0 to m - 1 do
+    begin
+      colmax := a[0][j];
+      for i := 1 to n - 1 do
+        if a[i][j] > colmax then
+          colmax := a[i][j];
+      if bsearch(rowmin, colmax) > -1 then
+        begin
+          setlength(res, length(res) + 1);
+          res[length(res) - 1] := colmax
+        end
+    end;
+  writeln(length(res));
+  for i in res do
+    write(i, ' ');
+  writeln
+end.