CROC 2013 A. Spyke Talks

 

 1 #include <iostream>
 2 #include <vector>
 3 #include <algorithm>
 4 #include <map>
 5 
 6 using namespace std;
 7 
 8 int main(){
 9     int n;
10     cin >> n;
11     map<int,int> id;
12     for(int i = 0; i <n; i ++ ){
13         int a;
14         cin >>a;
15         if(id.find(a) == id.end()) id[a] = 1;
16         else id[a]++;
17     }
18     int cnt = 0 ;
19     bool error = false;
20     for(map<int,int>::iterator it = id.begin(); it!=id.end(); it ++ ){
21         if(it->first == 0) continue;
22         if(it->second > 2){error = true; break;}
23         if(it->second == 2) cnt++;
24     }
25     if(error) cout<<-1<<endl;
26     else if(cnt) cout<<cnt<<endl;
27     else cout<<0<<endl;
28     return 0;
29 }

 

转载于:https://www.cnblogs.com/xiongqiangcs/archive/2013/04/14/3020983.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值