Pagini recente » Cod sursa (job #2709667) | Cod sursa (job #1063312) | Cod sursa (job #2240730) | Cod sursa (job #1246371) | Cod sursa (job #1708188)
#include <fstream>
#define MAX 6000003
using namespace std;
int n, v[MAX], maxx, I(1), J;
void read();
void solve();
void write();
int main()
{
read();
solve();
write();
return 0;
}
void read()
{
fstream fin ("ssm.in");
fin >> n;
for ( int i = 1; i <= n; ++i )
fin >> v[i];
fin.close();
}
void solve()
{
int ax, bst(0), j;
for ( int i = 1; i <= n; ++i )
{
ax = bst;
if ( ax + v[i] > v[i] )
{
bst = ax + v[i];
if ( maxx < bst )
I = j, J = i, maxx = bst;
}
else
{
j = i;
bst = v[i];
if ( maxx < bst )
I = j, J = i, maxx = bst;
}
}
}
void write()
{
fstream fout ( "ssm.out" );
fout << maxx << ' ' << I << ' ' << J << "\n";
fout.close();
}