Pagini recente » Monitorul de evaluare | Cod sursa (job #1174350) | Cod sursa (job #1477487) | Cod sursa (job #1870548) | Cod sursa (job #1659980)
#include <iostream>
#include <fstream>
using namespace std;
int
v[6000000];
int main()
{
int
s,
BIGGEST_S = -2000000000,
START_OF_V = 0,
END_OF_V,
n;
ifstream f("ssm.in");
ofstream o("ssm.out");
f>>n;
for(int i = 1; i <= n; i++)
f>>v[i];
for(int i = 1; i <= n; i++)
{
s = 0;
for(int j = i; j < n; j++)
{
s += v[j];
if(s > BIGGEST_S)
{
BIGGEST_S = s;
START_OF_V = i;
END_OF_V = j;
}
}
}
o<<BIGGEST_S << " "<< START_OF_V<< " "<< END_OF_V;
}