Pagini recente » Cod sursa (job #365355) | Cod sursa (job #3237469) | Cod sursa (job #1411935) | Cod sursa (job #2250400) | Cod sursa (job #1866251)
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
const int NMax = 6000005;
int X[NMax];
int N,A,B,Max = -2000000000;
int main()
{
fin >> N;
for(int i = 1; i <= N; ++i)
fin >> X[i];
for(int i = 1; i <= N; ++i)
{
int S = 0;
for(int j = i; j <= N; ++j)
{
S = S + X[j];
if(S > Max)
{
Max = S;
A = i; B = j;
}
}
}
fout << Max << " " << A << " " << B << "\n";
return 0;
}