Pagini recente » Cod sursa (job #1099706) | Cod sursa (job #2052308) | Cod sursa (job #866816) | Cod sursa (job #3277923) | Cod sursa (job #2043237)
#include <iostream>
#define Nmax 6000005
#include <fstream>
using namespace std;
int s[Nmax],v[Nmax];
int main()
{
ifstream cin ("ssm.in");
ofstream cout ("ssm.out");
int n,min1=210000000,max1=-2100000000,ind1,ind2;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>v[i];
s[i]=s[i-1]+v[i];
}
for(int i=1;i<=n;i++)
{
if(s[i-1]<min1)
{
min1=s[i-1];
ind1=i;
}
if(s[i]-min1>max1)
{
max1=s[i]-min1;
ind2=i;
}
}
cout<<max1<<" "<<ind1<<" "<<ind2;
return 0;
}