fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int back = 0, front = 0, count = 0;
  7. cin >> count;
  8. for (int coin = 0; count --> 0 && cin >> coin;) {
  9. (coin? back : front) += 1;
  10. }
  11. cout << min(back, front);
  12. return 0;
  13. }
Success #stdin #stdout 0s 4988KB
stdin
6
1 0 1 1 1 0
stdout
2