Pagini recente » Diferente pentru monthly-2012/runda-2 intre reviziile 6 si 3 | Istoria paginii utilizator/xorion | Diferente pentru utilizator/stay_awake77 intre reviziile 48 si 47 | Diferente pentru home intre reviziile 902 si 846 | Cod sursa (job #1583445)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{int poz1,poz,i,s,best,x,n,max,pozi;
fstream f("ssm.in",ios::in);
fstream g("ssm.out",ios::out);
f>>n;f>>s;poz1=1;best=s;max=-2000;
for(i=2;i<=n;i++)
{f>>s;
if(best<0)
{best=s;poz1=i;}
else
best=best+s;
if(best>max)
{max=best;
poz=poz1;
pozi=i;
}
}
g<<max<<" ";
cout<<max<<" "<<poz<<" "<<pozi;
g<<poz<<" "<<pozi;
g.close();
f.close();
}