about summary refs log tree commit diff
path: root/others/volume1/124.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-28 11:34:35 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-28 11:34:35 +0700
commitb7e55e6510690093d61f9cc1152e0330e55fe90b (patch)
tree36b48f77d96adaaaefc7728c8a95ca5d4342d653 /others/volume1/124.pas
parent7ebfa64719d4ac86b30075c65f21eafe9097853e (diff)
downloadcp-b7e55e6510690093d61f9cc1152e0330e55fe90b.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/124.pas')
-rw-r--r--others/volume1/124.pas28
1 files changed, 28 insertions, 0 deletions
diff --git a/others/volume1/124.pas b/others/volume1/124.pas
new file mode 100644
index 0000000..6a41c8e
--- /dev/null
+++ b/others/volume1/124.pas
@@ -0,0 +1,28 @@
+uses clib;
+
+var
+  m, n, i, k: int8;
+  a: intar;
+  s: array of array of ansistring;
+
+begin
+  readln(n, k);
+  setlength(a, n);
+  for i := 0 to n - 1 do
+    read(a[i]);
+  qsort(a);
+  m := 1;
+  for i := 1 to n - 1 do
+    if a[i] > a[i - 1] then
+      inc(m);
+  setlength(s, m);
+  for n := 0 to m - 1 do
+    begin
+      setlength(s[n], n + 2);
+      s[n][0] := '1';
+      for i := 1 to n do
+        s[n][i] := addintstr(s[n - 1][i], s[n - 1][i - 1]);
+      s[n][n + 1] := '0'
+    end;
+  writeln(addintstr(s[m - 1][k], s[m - 1][k - 1]))
+end.