Pagini recente » Cod sursa (job #3164335) | Diferente pentru problema/dijkstra intre reviziile 12 si 13 | Cod sursa (job #2944888) | Cod sursa (job #2355364) | Cod sursa (job #1722920)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int best,imax,jmax,i,j,n,x,maxi;
int main()
{
f>>n;
imax=1;
jmax=0;
maxi=-2147483647;
best=0;
for(i=1;i<=n;i++)
{
f>>x;
if(best+x>x)
{
best=best+x;
}
else
{
best=x;
imax=i;
}
if(best>maxi) jmax=j, maxi=best;
}
g<<maxi<<' '<<imax<<' '<<jmax<<' ';
return 0;
}