fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int h,w,one=0,zero=0;
  8. string n;
  9.  
  10. cin>>h>>w;
  11.  
  12. for(int i=0;i<h;i++){
  13. cin>>n;
  14.  
  15. for(int j=0;j<w;j++){
  16. if(n[j]=='1')
  17. one++;
  18. else
  19. zero++;
  20. }
  21. }
  22.  
  23. cout<<min(one,zero);
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5324KB
stdin
2 3
010
001
stdout
2