Pagini recente » Cod sursa (job #1176580) | Cod sursa (job #2575580) | Cod sursa (job #1480931) | Cod sursa (job #2137207) | Cod sursa (job #2163017)
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int x,n,i,st,dr,stmax,drmax;
long long smax,best[6000001];
int main()
{
fin>>n;
for (i=1;i<=n;i++)
{
fin>>x;
best[i]=x;
if (best[i]<best[i-1]+x) best[i]=best[i-1]+x;
if (best[i]>smax) {smax=best[i];drmax=i;stmax=st;}
if (best[i]==x) st=i;
}
fout<<smax<<" "<<stmax<<" "<<drmax<<'\n';
return 0;
}