Pagini recente » Cod sursa (job #644378) | Cod sursa (job #3040385) | Cod sursa (job #2017320) | Cod sursa (job #154753) | Cod sursa (job #3307191)
/*
https://infoarena.ro/problema/ssm
*/
#include <fstream>
#include <climits>
using namespace std;
int main()
{
ifstream in("ssm.in");
ofstream out("ssm.out");
int n, sc = -1, p, smax = INT_MIN, stmax, drmax;
in >> n;
for (int i = 0; i < n; i++)
{
int x;
in >> x;
if (x > sc + x)///0 > sc
{
sc = x;
p = i;
}
else
{
sc += x;
}
if (sc > smax)
{
smax = sc;
stmax = p;
drmax = i;
}
}
stmax++;
drmax++;
out << smax << " " << stmax << " " << drmax << endl;
in.close();
out.close();
return 0;
}