fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,m;
  7. cin>>n>>m;
  8. int a[100][100];
  9. for(int i=0;i<n;i++)
  10. for(int j=0;j<m;j++)
  11. cin>>a[i][j];
  12. int l,c;
  13. c=0;
  14. int b[100];
  15. l=0;
  16. int temp;
  17. for(int i=0;i<n;i++)
  18. for(int j=0;j<m;j++)
  19. {
  20. for(int k=j+1;k<m;k++)
  21. {
  22. if(a[i][j]==1||a[i][k]==1)
  23. c++;
  24.  
  25. }
  26. b[l]=c;
  27. l++;
  28.  
  29.  
  30. }
  31. for(int i=0;i<l-1;i++)
  32. for(int j=0;j<n-i-1;j++)
  33. {
  34. if(b[j]>b[j+1])
  35. {
  36. temp=b[j];
  37. b[j]=b[j+1];
  38. b[j+1]=temp;
  39.  
  40.  
  41. }
  42. }
  43. int x=1;
  44. int item=b[l-1];
  45. for(int i=0;i<l;i++)
  46. {
  47. if(item==b[i])
  48. x++;
  49.  
  50. }
  51. cout<<b[l-1]<<endl;
  52. cout<<x;
  53.  
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 4544KB
stdin
4 5
10101
11100
11010
00101
stdout
0
21