diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-11-10 16:05:26 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-11-10 16:05:26 +0200 |
| commit | 95422138588572e08a1ee78e654741874f11cfa0 (patch) | |
| tree | 1a03ad9c57788546e804724ed4507f46c385263d /contests/filtrationContest | |
| parent | 42e25addbbce62e8bb43ab587b21c5bccb495bfb (diff) | |
| download | competitive-programming-95422138588572e08a1ee78e654741874f11cfa0.tar.xz competitive-programming-95422138588572e08a1ee78e654741874f11cfa0.zip | |
Added some new problems
Diffstat (limited to 'contests/filtrationContest')
| -rwxr-xr-x | contests/filtrationContest/C/main | bin | 22528 -> 50432 bytes | |||
| -rw-r--r-- | contests/filtrationContest/C/main.cpp | 26 |
2 files changed, 11 insertions, 15 deletions
diff --git a/contests/filtrationContest/C/main b/contests/filtrationContest/C/main Binary files differindex 4fad05f..b207653 100755 --- a/contests/filtrationContest/C/main +++ b/contests/filtrationContest/C/main 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'; } |
