fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(){
  5. int n, i, k, a = 0, b = 0;
  6. scanf("%d", &n);
  7. for (i = 0; i < n; i++){
  8. scanf("%d", &k);
  9. if (k == 1){ a++; }else{ b++; }
  10. }
  11. printf("%d", abs(a - b));
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0.01s 5428KB
stdin
Standard input is empty
stdout
Standard output is empty