Pagini recente » Cod sursa (job #2035870) | Cod sursa (job #1135321) | Cod sursa (job #2353062) | Cod sursa (job #3284585) | Cod sursa (job #497761)
Cod sursa(job #497761)
#include<fstream>
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
int main()
{
int x,sc,smax,stc,stmax,drmax,n,i;
sc = 0;
stc = 1;
smax = -2000000000;
in>>n;
for (i =1;i<=n;++i)
{
in>>x;
if(sc<0)
{
sc = 0;
stc = i;
}
sc+=x;
if(sc > smax)
{
smax = sc ;
stmax = stc;
drmax = i;
}
}
out << smax << ' ' << stmax << ' ' << drmax << '\n';;
return 0;
}