Pagini recente » Cod sursa (job #650558) | Cod sursa (job #3165083) | Cod sursa (job #79555) | Cod sursa (job #1202894) | Cod sursa (job #2666778)
#include <fstream>
using namespace std;
int main()
{
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n;
fin >> n;
int sc=0,smax=-2147483648,lc=0,dr;
for(int i=1;i<=n;i++)
{
int x;
fin >> x;
lc++;
if(sc<0)
{
sc=0;
lc=0;
}
sc += x;
if(sc>smax)
{
smax=sc;
dr=i;
}
}
if(dr!=1)
fout << smax << " " << dr-lc+1 << " " << dr << endl;
else
fout << smax << " " << 1 << " " << 1 << endl;
fout.flush();
return 0;
}