Pagini recente » Cod sursa (job #2067794) | Cod sursa (job #142246) | Cod sursa (job #1597862) | Cod sursa (job #118563) | Cod sursa (job #1837810)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int n , x , S , Smax , imax , jmax , i , index;
int main()
{
Smax = -299999999;
f >> n;
for ( int i = 1; i <= n ; i++ )
{
f >> x;
if ( S < 0 ) S = x, index = i;
else S += x;
if ( Smax < S ) Smax = S , imax = index, jmax = i;
}
g << Smax << " " << imax << " " << jmax ;
return 0;
}