Pagini recente » Cod sursa (job #1596026) | Cod sursa (job #858317) | Cod sursa (job #64835) | Cod sursa (job #785498) | Cod sursa (job #3283488)
#include <fstream>
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
const int INF = 2e9;
const int N = 5000000;
int v[N];
int main()
{
int n;
in >> n;
int s_max = -INF, s_c = 0;
int st, dr, st_max, dr_max;
st = dr = st_max = dr_max = 0;
for (int i = 0; i < n; i++)
{
in >> v[i];
if (s_c > 0)
{
s_c += v[i];
dr = i;
}
else
{
s_c = v[i];
st = dr = i;
}
if (s_c > s_max)
{
s_max = s_c;
dr_max = dr;
st_max = st;
}
}
dr_max++;
st_max++;
out << s_max << ' ' << st_max << ' ' << dr_max;
in.close();
out.close();
return 0;
}