NYOJ286 动物统计
简单题。
附ac代码:
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(){ int n; vector<string> vec; vector<int> inde; string str; cin >> n; while(n--){ cin >> str; vector<string>::iterator fin; fin = find(vec.begin(), vec.end(), str); if(fin != vec.end()) ++inde[fin - vec.begin()]; else{ vec.push_back(str); inde.push_back(1); } } //找到最大值 vector<int>::iterator ite = max_element(inde.begin(), inde.end()); cout << vec[ite - inde.begin()] << ' ' << *ite << endl; return 0; }