You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int n;
|
|
|
|
|
cin >> n;
|
|
|
|
|
unordered_map<int, int> _map;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
int c;
|
|
|
|
|
cin >> c;
|
|
|
|
|
if (c > 0) {
|
|
|
|
|
_map[c] = 1;
|
|
|
|
|
} else {
|
|
|
|
|
if (_map.count(abs(c)) > 0) {
|
|
|
|
|
_map[abs(c)]++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//遍历map,找到值为2的
|
|
|
|
|
int count = 0;
|
|
|
|
|
unordered_map<int, int>::iterator it = _map.begin();
|
|
|
|
|
while (it != _map.end()) {
|
|
|
|
|
if (it->second == 2) count++;
|
|
|
|
|
it++;
|
|
|
|
|
}
|
|
|
|
|
cout << count << endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|