Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA了。。。。怎么回事#include<iostream> #include<string> #include<map> using namespace std; int main() { string candidate[20][2],tmpstr; int VOTES[20]; map<string , int>mapstr; int n,m; cin>>n;getchar(); for(int i=0;i<n;i++){ getline(cin,candidate[i][0]); getline(cin,candidate[i][1]); } cin>>m;getchar(); for(int i=0;i<m;i++){ getline(cin,tmpstr); if(!mapstr.count(tmpstr)){ mapstr[tmpstr]=1; } else mapstr[tmpstr]++; } int maxvote=0,maxcount=0,maxpos=0; for(int i=0;i<n;i++){ VOTES[i]=mapstr[candidate[i][0]]; if(maxvote<VOTES[i]){ maxvote=VOTES[i]; maxpos=i; } } for(int i=0;i<n;i++){ if(VOTES[i]==maxvote){ ++maxcount; } } if(maxcount>1)puts("tie"); else { cout<<candidate[maxpos][1]<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator