Pagini recente » Cod sursa (job #440727) | Cod sursa (job #2926243) | Cod sursa (job #255801) | clasament-arhiva-educationala | Cod sursa (job #2853182)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n, nr, smax, bestprec, stprec, stmax, drmax;
int main()
{
fin >> n >> nr;
smax = bestprec = nr;
stprec = stmax = drmax = 1;
for(int i = 2; i <= n; i++)
{
fin >> nr;
int besti, sti;
if(bestprec < 0)
{
besti = nr;
sti = i;
}
else
{
besti = bestprec + nr;
sti = stprec;
}
if(besti > smax)
{
smax = besti;
stmax = sti;
drmax = i;
}
bestprec = besti;
stprec = sti;
}
fout << smax << ' ' << stmax << ' ' << drmax;
return 0;
}