Pagini recente » Cod sursa (job #1801615) | Cod sursa (job #1047358) | Cod sursa (job #1653433) | Cod sursa (job #694983) | Cod sursa (job #2043242)
#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=2100000000,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;
}