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