Pagini recente » Cod sursa (job #106439) | Cod sursa (job #27591) | Cod sursa (job #107995) | Cod sursa (job #283295) | Cod sursa (job #3249099)
#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 or (s == smax and poz < pozmax) or (s == smax and poz == pozmax and l < lmax)){
smax = s;
lmax = l;
pozmax = poz;
}
}
fout << smax << ' ' << pozmax << ' ' << pozmax + lmax - 1;
}