Pagini recente » Cod sursa (job #265757) | Cod sursa (job #916462) | Cod sursa (job #1571905) | Cod sursa (job #2375810) | Cod sursa (job #1863654)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int N;
long long s, smax;
long long x;
int sc, dc, st, dr;
int main()
{
fin >> N;
for ( int i = 1; i <= N; ++i )
{
fin >> x;
if ( s + x > x )
s = s + x, dc++;
else
s = x, sc = dc = i;
if ( smax < s )
{
smax = s;
st = sc;
dr = dc;
}
}
fout << smax << ' ' << st << ' ' << dr << '\n';
fin.close();
fout.close();
return 0;
}