Pagini recente » Cod sursa (job #118196) | Cod sursa (job #1033531) | Statistici Morosan Teodor (Morosan_Teodor) | Cod sursa (job #2717170) | Cod sursa (job #1817809)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int main(){
ifstream cin("ssm.in");
ofstream cout("ssm.out");
lli best = -maxLong,sum = 0;
int n;
cin >> n;
int lft , rgh, pa, pb;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
if(sum < 0){
sum = x;
pa = i;
pb = i;
} else {
pb = i;
sum += x;
}
if(sum > best){
best = sum;
lft = pa;
rgh = pb;
}
}
cout << best << ' ' << lft << ' ' << rgh << endl;
return(0);
}