Pagini recente » Cod sursa (job #2703296) | Cod sursa (job #3156188) | Cod sursa (job #1445863) | Cod sursa (job #2466873) | Cod sursa (job #2814244)
#include <fstream>
using namespace std;
int main(){
ifstream fin ("ssm.in");
ofstream fout ("ssm.out");
int n, a, ult, start, stop, k;
long long sm = ( 1 << 31 );
fin >> n >> a;
ult = a;
for (int i = 1; i < n; ++i){
fin >> a;
if (ult > 0)
ult += a;
else {
ult = a;
k = i;
}
if (ult > sm){
sm = ult;
start = k;
stop = i;
}
}
fout << sm << " " << start + 1 << " " << stop + 1;
return 0;
}