# J. Parallelograms

J. Parallelograms
time limit per test
2.0 s
memory limit per test
256 MB
input
standard input
output
standard output

There are n sticks, the i-th of which has length ai. Alex wants to assemble from them as many parallelograms as possible simultaneously, with each stick used at most in one parallelogram. What maximal number of parallelograms is it possible to assemble?

Input

The first line contains a single integer n (1 ≤ n ≤ 200000) — the number of sticks.

The second line contains n integers ai (1 ≤ ai ≤ 200000) — the lengths of sticks.

Output

Output a single integer — the maximal number of parallelograms that is possible to assemble.

Examples
input
Copy
4
1 2 1 2

output
Copy
1

input
Copy
12
1 3 5 7 1 3 5 7 1 3 5 7

output
Copy
2


#### 题意：给你n个棍子，然后第二行是每个棍子的长度。问最多能够组成多少平行四边形。 题解：模拟  记录每种长度的棍子，然后如果是奇数的话，棍子数减1，因为我们只会用到偶数棍子。因为一个平行四边形是四条边。最后把每种长度的棍子数加起来/4就是答案。

#include<bits/stdc++.h>
using namespace std;
int n,a[200100],sum=0,x;
int main()
{

cin>>n;
for(int i=0; i<n; i++)
cin>>x,a[x]++;
for(int i=0; i<=200000; i++)
{
if(a[i]&1)
a[i]--;
sum+=a[i],a[i]=0;
}
cout<<sum/4<<endl;
return 0;
}

Memory丿浅笑

• 擅长领域：
• python
• c++
• 爬虫