Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("secventa.in");
- ofstream fout("secventa.out");
- int n;
- int main()
- {
- fin >> n;
- int x, y, cnt = 1, st, lmax = 0, stMax;
- long long sum = 0, sumMax = 0;
- fin >> x;
- sum += x;
- for (int i = 2; i <= n; ++i)
- {
- fin >> y;
- if (y % 2 != x % 2)
- {
- if (cnt == 1)
- st = i - 1;
- cnt++;
- sum += y;
- }
- else
- {
- cnt = 1;
- sum = y;
- }
- if (cnt > lmax)
- {
- lmax = cnt;
- sumMax = sum;
- stMax = st;
- }
- else
- if (cnt == lmax && sum >= sumMax)
- {
- sumMax = sum;
- stMax = st;
- }
- x = y;
- }
- fout << stMax << ' ' << stMax + lmax - 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement