Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<climits>
- using namespace std;
- ifstream fin("secvmax.in");
- ofstream fout("secvmax.out");
- int v[10005];
- int lcr, start, stop, suma;
- int main()
- {
- int i, smax=INT_MIN, x, n, lmax=INT_MIN;
- fin>>n;
- for(i=1; i<=n; i++)
- {
- fin>>x;
- if(x%2==0)
- {
- lcr++;
- suma=suma+x;
- }
- else
- {
- if(lcr>=lmax)
- {
- if(suma>smax)
- {
- lmax=lcr;
- start=i-lcr;
- }
- }
- lcr=0;
- suma=0;
- }
- }
- if(lcr>lmax)
- {
- if(suma>smax)
- {
- lmax=lcr;
- start=i-lcr;
- }
- }
- stop=start+lmax-1;
- fout<<start<<" "<<stop;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement