Pagini recente » Cod sursa (job #3236153) | Cod sursa (job #502368) | Cod sursa (job #1005397) | Cod sursa (job #2154327) | Cod sursa (job #1539782)
#include <iostream>
#include <fstream>
#include <string.h>
#include <limits.h>
//#include <vector>
//#include <queue>
//#include <algorithm>
using namespace std;
const int nmax = 6000003;
int n;
int a[nmax];
int main(){
freopen("ssm.in", "r", stdin);
freopen("ssm.out", "w", stdout);
scanf("%d", &n);
a[0] = 0;
for (int x,i = 1; i <= n; i++){
scanf("%d", &x);
a[i] = a[i - 1] + x;
}
int min = 0, minInd = 1, max = a[1], maxInd = 1;
for (int i = 1; i <= n; i++){
if (a[i] < min) { min = a[i]; minInd = i+1; };
if (a[i] - min > max) { max = a[i] - min; maxInd = i; };
}
printf("%d %d %d", max, minInd, maxInd);
fclose(stdin);
fclose(stdout);
return 0;
}