Pagini recente » Cod sursa (job #1513751) | Cod sursa (job #2068375) | Cod sursa (job #48780) | Cod sursa (job #809725) | Cod sursa (job #1766072)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
const int MAXN=6000001;
int n,best[MAXN],smax=-200000000,x,in,sf,inmax;
int main()
{
f>>n;
for(int i=1;i<=n;i++)
{
f>>x;
best[i]=x;
if(best[i]<=best[i-1]+x)
best[i]=best[i-1]+x;
else in=i;
if(smax<best[i])
{
smax=best[i];
inmax=in;
sf=i;
}
}
g<<smax<<' '<<inmax<<' '<<sf;
return 0;
}