about summary refs log tree commit diff
path: root/2ndary/10/CSP-KT2/negpairs.c
diff options
context:
space:
mode:
Diffstat (limited to '2ndary/10/CSP-KT2/negpairs.c')
-rw-r--r--2ndary/10/CSP-KT2/negpairs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/2ndary/10/CSP-KT2/negpairs.c b/2ndary/10/CSP-KT2/negpairs.c
new file mode 100644
index 0000000..577fdf8
--- /dev/null
+++ b/2ndary/10/CSP-KT2/negpairs.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int main()
+{
+	long n, i;
+	long unsigned_a[201] = {};
+	long *a = &unsigned_a[100];
+	char a0;
+	long long v;
+
+	scanf("%ld", &n);
+	for (i = 0; i < n; i++) {
+		scanf("%hhd", &a0);
+		a[a0]++;
+	}
+
+	v = a[0] * (a[0] - 1) / 2;
+	for (i = 1; i <= 100; i++)
+		v += a[i] * a[-i];
+
+	printf("%lld\n", v);
+
+	return 0;
+}