fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int main(){
  5. int a, b = 0, c = 0;
  6. cin >> a;
  7. do{
  8. if(a != 0 && b < 2){
  9. a = a + c;
  10. c = a;
  11. b = 0;
  12. }
  13. else{
  14. b++;
  15. }
  16. }while(cin >> a);
  17. cout << c;
  18. return 0;
  19. }
Success #stdin #stdout 0s 5288KB
stdin
1 5 5 5 2 0 5
stdout
23