Advertisement
STANAANDREY

sb3 3 bac2020 t20

May 16th, 2022
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("bac.txt");
  4.  
  5. int main() {
  6.     int a, b;
  7.     fin >> a;
  8.     int sum = a, maxSum = sum;
  9.     while (fin >> b) {
  10.         if (a % 2 == b % 2) {
  11.             sum += b;
  12.         } else {
  13.             maxSum = max(maxSum, sum);
  14.             sum = b;
  15.         }
  16.         a = b;
  17.     }
  18.     cout << maxSum << endl;
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement