title: 2 player team knowing maximum moves
body: <p>Given a list of N players who are to play a 2 player game. Each of them are either well versed in making a particular move or they are not. Find out the maximum number of moves a 2-player team can know.</p>
  
  <p>And also find out how many teams can know that maximum number of moves?</p>
  
  <p>Example Let we have 4 players and 5 moves with ith player is versed in jth move if a[i][j] is 1 otherwise it is 0.</p>
  
  <pre><code>10101
  11100
  11010 
  00101
  </code></pre>
  
  <p>Here maximum number of moves a 2-player team can know is 5 and their are two teams that can know that maximum number of moves.</p>
  
  <p><strong>Explanation</strong> : (1, 3) and (3, 4) know all the 5 moves. So the maximal moves a 2-player team knows is 5, and only 2 teams can acheive this.</p>
  
  <p><strong>My approach</strong> : For each pair of players i check if any of the players is versed in ith move or not and for each player maintain the maximum pairs he can make with other players with his local maximum move combination.</p>
  
  <pre><code>vector&lt;int&gt; pairmemo;
  for(int i=0;i&lt;n;i++){
      int mymax=INT_MIN;
      int countpairs=0;
      for(int j=i+1;j&lt;n;j++){
          int count=0;
              for(int k=0;k&lt;m;k++){
                  if(arr[i][k]==1 || arr[j][k]==1)
                  {
                      count++;
                  }
          }
          if(mymax&lt;count){
              mymax=count;
              countpairs=0;
          }
          if(mymax==count){
              countpairs++;
          }
  
      }
      pairmemo.push_back(countpairs);
      maxmemo.push_back(mymax);
  }
  </code></pre>
  
  <p>Overall maximum of all N players is answer and count is corresponding sum of the pairs being calculated.</p>
  
  <pre><code>for(int i=0;i&lt;n;i++){
      if(maxi&lt;maxmemo[i])
          maxi=maxmemo[i];
  }
  
  int countmaxi=0;
  
  for(int i=0;i&lt;n;i++){
      if(maxmemo[i]==maxi){
          countmaxi+=pairmemo[i];
      }
  }
  
  cout&lt;&lt;maxi&lt;&lt;"\n";
  cout&lt;&lt;countmaxi&lt;&lt;"\n";
  </code></pre>
  
  <p>Time complexity : O((N^2)*M)</p>
  
  <p>Code : 
  How can i improve it?</p>
  
  <p>Constraints : N&lt;= 3000 and M&lt;=1000</p>