Pagini recente » Cod sursa (job #2357005) | Cod sursa (job #771456) | Cod sursa (job #1833829) | Monitorul de evaluare | Cod sursa (job #3249096)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n, x, s, smax, pozmax, lmax, poz, l;
int main(){
fin >> n;
poz = 1;
for(int i = 1; i <= n; ++i){
fin >> x;
if(s >= 0){
s = s + x;
++l;
}
else{
s = x;
poz = i;
l = 1;
}
if(s > smax){
smax = s;
lmax = l;
pozmax = poz;
}
}
fout << smax << ' ' << pozmax << ' ' << pozmax + lmax - 1;
}