Hatena::Grouptopcoder

yakk512の日記

 | 

2014-02-22

チーター本で練習ーみんなが楽しいパーティ

01:31

共通の話題を何人が持っているかを数える.

class InterestingParty 
{

public:
  int count( string topic , vector <string> first , vector <string> second )
  {
    int res = 0;
    for(int i = 0; i < first.size(); i++)
      {
	if( topic == first[i] || topic == second[i] )
	  {
	    res++;
	  }
      }
    return res;
  }

public:
  int bestInvitation(vector <string> first, vector <string> second) 
  {

    int result = 0;

    for(int i = 0; i < first.size(); i++)
      {
	result = max(result , max(count( first[i] , first , second ) , count( second[i] , first ,second ) ) );
      }
    return result;
  }

};
 |