Advertisement
cupsamada

166

Mar 6th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<climits>
  4. using namespace std;
  5. ifstream fin("secvmax.in");
  6. ofstream fout("secvmax.out");
  7. int v[10005];
  8. int lcr, start, stop, suma;
  9. int main()
  10. {
  11. int i, smax=INT_MIN, x, n, lmax=INT_MIN;
  12. fin>>n;
  13. for(i=1; i<=n; i++)
  14. {
  15. fin>>x;
  16. if(x%2==0)
  17. {
  18. lcr++;
  19. suma=suma+x;
  20. }
  21. else
  22. {
  23. if(lcr>=lmax)
  24. {
  25. if(suma>smax)
  26. {
  27. lmax=lcr;
  28. start=i-lcr;
  29. }
  30. }
  31. lcr=0;
  32. suma=0;
  33. }
  34. }
  35. if(lcr>lmax)
  36. {
  37. if(suma>smax)
  38. {
  39. lmax=lcr;
  40. start=i-lcr;
  41. }
  42. }
  43. stop=start+lmax-1;
  44. fout<<start<<" "<<stop;
  45. fin.close();
  46. fout.close();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement