Pagini recente » Cod sursa (job #305789) | Cod sursa (job #1252302) | Atasamentele paginii 3423523451 | Istoria paginii runda/boji_round9 | Cod sursa (job #2308566)
#include<fstream>
#include<iostream>
#include<algorithm>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
void SSM()
{
int N, i, smax, s, x, st, dr, stmax, drmax;
fin >> N;
fin >> s;
smax = s;
st = stmax = 1;
dr = drmax = 1;
for (i = 1; i < N; i++)
{
fin >> x;
s += x;
if (s > smax)
{
smax = s;
drmax = i;
stmax = st;
}
if (s < 0)
{
s = 0;
st = i+1;
}
}
fout << smax << ++stmax << ++drmax << "\n";
}
int main ()
{
SSM();
return 0;
}