Pagini recente » Cod sursa (job #1742709) | Cod sursa (job #2633971) | Cod sursa (job #2465154) | Cod sursa (job #42008) | Cod sursa (job #1817803)
#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");
int best = 0,sum = 0;
int n;
cin >> n;
int lft , rgh, pa, pb;
if(n == 1){
int x;
cin >> x;
return cout << x << ' ' << 1 << ' ' << 1, 0;
}
for(int i = 1; i <= n; i++){
int x;
cin >> x;
if(sum < 0){
sum = x;
pa = i;
} else {
pb = i;
sum += x;
}
if(sum > best){
best = sum;
lft = pa;
rgh = pb;
}
}
cout << best << ' ' << lft << ' ' << rgh << endl;
return(0);
}