Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("bac.txt");
- int main() {
- int a, b;
- fin >> a;
- int sum = a, maxSum = sum;
- while (fin >> b) {
- if (a % 2 == b % 2) {
- sum += b;
- } else {
- maxSum = max(maxSum, sum);
- sum = b;
- }
- a = b;
- }
- cout << maxSum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement