Pagini recente » Cod sursa (job #2190668) | Cod sursa (job #2461005) | Cod sursa (job #63223) | Cod sursa (job #1015486) | Cod sursa (job #2575205)
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
const int NMAX = 6000005;
const int INF = 2e9;
int main()
{
int n,x;
int sc = 0,stc = 0,stmax=1,drmax=1, scmax = -INF;
fin >> n;
for (int i = 1; i <= n; i++)
{
fin >> x;
if (sc + x >= x)
sc += x;
else
{
sc = x;
stc = i;
}
if (sc > scmax)
{
scmax = sc;
stmax = stc;
drmax = i;
}
}
fout << scmax << " " << stmax << " " << drmax << "\n";
return 0;
}