Pagini recente » Cod sursa (job #2873721) | Monitorul de evaluare | Cod sursa (job #1137739) | Istoria paginii info-oltenia-2019 | Cod sursa (job #1279861)
#include <fstream>
using namespace std;
ifstream fin ("ssm.in");
ofstream fout ("ssm.out");
int n,i,s,inceput,sfarsit,x,maxi,c;
int main()
{
fin>>n;
fin>>x;
s=x; maxi=s;
for(i=1;i<n;i++)
{
fin>>x;
s=max(s+x,x);
if(s==x)
c=i+1;
if(s>maxi)
{
maxi=s;
inceput=c;
sfarsit=i+1;
}
}
fout<<maxi<<" "<<inceput<<" "<<sfarsit<<'\n';
fin.close();
fout.close();
return 0;
}