Pagini recente » Cod sursa (job #1840028) | Cod sursa (job #1382401) | Cod sursa (job #2181104) | Cod sursa (job #405104) | Cod sursa (job #2209666)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
//int a[60000001];
//int dp[60000001];
int best,d,curent,x,N,jmax,imax ;
int maxi(int a,int b)
{
return a>b ? a:b;
}
int main()
{
fin>>N>>x;
best = x;
curent = x;
d = x;
imax = jmax = 1;
for (int i=2;i<=N;i++)
{
fin>>x;
if (x > d+x) imax = i;
d = maxi(x,d+x);
if (d>best)
{
best = d;
jmax = i;
}
}
fout<<best<<' '<<imax<<' '<<jmax;
return 0;
}