Pagini recente » Cod sursa (job #3037553) | Cod sursa (job #3187540) | Cod sursa (job #2079242) | Cod sursa (job #3164064) | Cod sursa (job #2324044)
#include <bits/stdc++.h>
using namespace std;
ifstream f ("ssm.in");
ofstream g ("ssm.out");
int x,n,i,s[6000000],pmin,st,dr,mini,p2,smax,rez;
int main()
{
f>>n;
for(i=1;i<=n;i++){
f>>x;
s[i]=s[i-1]+x;
}
rez=-200000000;
mini=0;
pmin=0;
for(p2=1;p2<=n;p2++){
smax=s[p2]-mini;
if(smax>rez){
rez=smax;
st=pmin;
dr=p2;
}
if(s[p2]<mini)
{
mini=s[p2];
pmin=p2;
}
}
g<<rez<<' '<<st+1<<' '<<dr;
return 0;
}