Codeforces Beta Round #93 (Div. 2 Only)——B

B. Canvas Frames
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.

Nicholas has n sticks whose lengths equal a1, a2, ... an. Nicholas does not want to break the sticks or glue them together. To make a h × w-sized frame, he needs two sticks whose lengths equal h and two sticks whose lengths equal w. Specifically, to make a square frame (when h = w), he needs four sticks of the same length.

Now Nicholas wants to make from the sticks that he has as many frames as possible; to be able to paint as many canvases as possible to fill the frames. Help him in this uneasy task. Note that it is not necessary to use all the sticks Nicholas has.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of sticks. The second line contains n space-separated integers. The i-th integer equals the length of the i-th stick ai (1 ≤ ai ≤ 100).

Output

Print the single number — the maximum number of frames Nicholas can make for his future canvases.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxn 110
using namespace std;
int cnt[maxn];
int main()
{
    int n,i;
    scanf("%d",&n);
    memset(cnt,0,sizeof(cnt));
    int x;
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        cnt[x]++;
    }
    int sum=0;
    for(i=1;i<=100;i++)
    {
        cnt[i]/=2;//每2条相同的边才能构成矩形,每个1代表一对同边
        sum+=cnt[i];
    }
    printf("%d\n",sum/2);//构成矩形需要2对同边
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值