Pagini recente » Clasament itmarathon2015 | Cod sursa (job #684098) | Cod sursa (job #1685721) | Cod sursa (job #2275140) | Cod sursa (job #1539772)
#include <iostream>
#include <fstream>
#include <string.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;
int x, min = 1 << 30, minInd = 0, max = 0, maxInd = 0;
for (int i = 1; i <= n; i++){
scanf("%d", &x);
a[i] = a[i - 1] + x;
if (a[i] < min) { min = a[i]; minInd = i; };
if (a[i] - min > max) { max = a[i] - min; maxInd = i; };
}
printf("%d %d %d", max, minInd+1, maxInd);
fclose(stdin);
fclose(stdout);
return 0;
}