about summary refs log tree commit diff
path: root/2ndary/09/TP-HN-2014/cau2.cpp
diff options
context:
space:
mode:
Diffstat (limited to '2ndary/09/TP-HN-2014/cau2.cpp')
-rw-r--r--2ndary/09/TP-HN-2014/cau2.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/2ndary/09/TP-HN-2014/cau2.cpp b/2ndary/09/TP-HN-2014/cau2.cpp
new file mode 100644
index 0000000..8c87168
--- /dev/null
+++ b/2ndary/09/TP-HN-2014/cau2.cpp
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+int
+main()
+{
+  ifstream infile;
+  infile.open("CAU2.INP");
+  short n, i, j;
+  long d, count = 0;
+  infile >> n >> d;
+  short* v = (short*) malloc(n * sizeof(short));
+  for (i = 0; i < n; i++)
+    {
+      infile >> v[i];
+      for (j = 0; j < i; j++)
+        if (d * (v[i] - v[j]) > v[i] * v[j] * (i - j))
+          count++;
+    }
+  infile.close();
+  free(v);
+
+  ofstream outfile;
+  outfile.open("CAU2.OUT");
+  outfile << count << endl;
+  outfile.close();
+
+  return 0;
+}