Pagini recente » Cod sursa (job #1848405) | Cod sursa (job #2041363) | Cod sursa (job #3148188) | Cod sursa (job #2271819) | Cod sursa (job #1922715)
#include <iostream>
#include <stdio.h>
using namespace std;
int maxSUM = -1000000, minSUM = 1000000;
int mx, mi, begi;
int SUM;
int main () {
freopen("ssm.in", "r", stdin);
freopen("ssm.out", "w", stdout);
long long Load, Present, S;
cin >> Load;
cin >> Present;
S = Present;
for (int i = 1; i < Load; i++) {
scanf("%lld", &Present);
if (S >= 0)
S += Present;
else {
S = Present;
begi = i;
}
if (S > maxSUM) {
maxSUM = S, mx = i; mi = begi;
}
}
cout << maxSUM << " " << mi + 1 << " " << mx + 1;
}