Advertisement
DaniDori

Untitled

Oct 8th, 2022
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n, countC=0, countN=0, sumC=0, sumN=0, x, buf;
  6. cin >> n;
  7. for(int i=0; i<n; i++){
  8. cin >> x;
  9. if (x % 2) {
  10. countC ++;
  11. sumC += x;
  12. }
  13. else
  14. {
  15. countN++;
  16. sumN += x;
  17. }
  18. }
  19. while (scanf("%1d", &x)) {
  20. if (x) {
  21. countN += countC;
  22. countC = 0;
  23. sumN += sumC/2;
  24. sumC = 0;
  25. }
  26. else {
  27. countC += countN;
  28. sumC += sumN+countN;
  29. sumC = 0;
  30. countC = 0;
  31. }
  32. }
  33. cout << sumC + sumN;
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement