aboutsummaryrefslogtreecommitdiff
path: root/contests/filtrationContest/C/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contests/filtrationContest/C/main.cpp')
-rw-r--r--contests/filtrationContest/C/main.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/contests/filtrationContest/C/main.cpp b/contests/filtrationContest/C/main.cpp
index 0d06899..e3ed80c 100644
--- a/contests/filtrationContest/C/main.cpp
+++ b/contests/filtrationContest/C/main.cpp
@@ -1,23 +1,19 @@
#include<bits/stdc++.h>
-
+
using namespace std;
-
-int64_t fq[22];
-
+
int main () {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
long long n;
cin >> n;
- for (int i = 1; i <= n; i++) {
- int64_t x;
+ long long ans = 0;
+ map<long long, long long> fq;
+ for(int i = 0; i < n; i++) {
+ long long x;
cin >> x;
- fq[10 + x]++;
+ ans += fq[x];
+ fq[-x]++;
}
- int64_t ans = 0;
- for (int i = 1;i <= 10; i++) {
- ans += fq[10 - i] * fq[10 + i];
- }
- ans += fq[10] * (fq[10] - 1) / 2;
- cout << ans;
+ cout << ans << '\n';
}