TopCoder High School SRM 23 Level one - 250 pt - Good Exhibition editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm23
TopCoder High School SRM 23 Level one - 250 pt - Good Exhibition solution:
#include <iostream> #include <vector> #include <map> using namespace std; class GoodExhibition { public: int numberOfPictures(vector <string> l, int k) { int cnt=0; map <string, int> a; for(int i=0; i<l.size(); i++) a[l[i]]++; for(map <string, int>::iterator i=a.begin(); i!=a.end(); i++) { if((*i).second>k-1) cnt+=k-1; else cnt+=(*i).second; } return cnt; } };
No comments:
Post a Comment