Pagini recente » Cod sursa (job #919408) | Cod sursa (job #911418) | Cod sursa (job #994141) | Cod sursa (job #2677783) | Cod sursa (job #2409030)
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int main()
{
long long n,i,secv=0,x,l=1,y,smin,smax,s=0,pmin,pmax,aux;
f>>n;
f>>x;
smax=x;
smin=x;
pmin=1;pmax=1;
s=x;
for(i=2;i<=n;i++)
{
f>>x;
s=s+x;
if(s<smin )
smin=s,pmin=i+1;
if(s-smin>smax)
smax=s-smin,pmax=i;
}
g<<smax<<" ";
/*if(pmin>pmax)
{
aux=pmin;
pmin=pmax;
pmax=aux;
}*/
g<<pmin<<" "<<pmax;
}