Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Created January 6, 2013 22:55
Show Gist options
  • Select an option

  • Save tsu-nera/4470858 to your computer and use it in GitHub Desktop.

Select an option

Save tsu-nera/4470858 to your computer and use it in GitHub Desktop.
/*
* TopCoder
* SRM494 Div2 Level1
*/
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
class InterestingParty {
public:
int bestInvitation(vector<string> first, vector<string> second) {
map<string, int> dic;
for (int i = 0; i < first.size(); i++) {
dic[first[i]] = 0;
dic[second[i]] = 0;
}
for (int j = 0; j < first.size(); j++) {
dic[first[j]]++;
dic[second[j]]++;
}
int ans = 0;
map<string, int>::iterator it;
for( it=dic.begin(); it!=dic.end(); it++ ) {
if( ans < it->second ) {
ans = it->second;
}
}
return ans;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment