fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[20];
  6. for (int i = 0; i < 20; i++) {
  7. cin >> a[i];
  8. }
  9. int min = 21;
  10. for (int i = 0; i < 20; i++) {
  11. if (a[i] == 1) {
  12. for (int j = i + 1; j < 20; j++) {
  13. if (a[j] == 0) {
  14. int d = j - i - 1;
  15. if (d < min) {
  16. min = d;
  17. }
  18. break;
  19. }
  20. }
  21. }
  22. }
  23.  
  24. if (min == 21) {
  25. cout << -1 << endl;
  26. } else {
  27. cout << min << endl;
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5288KB
stdin
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
stdout
0