Pagini recente » Cod sursa (job #5000) | Cod sursa (job #364265) | Cod sursa (job #3143111) | Cod sursa (job #1329617) | Cod sursa (job #1964168)
#include <bits/stdc++.h>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int n,a[6000001],best[6000001],inc,sf,id,bestSum;
int main()
{
f>>n;
bestSum=a[1];
for(int i=1;i<=n;i++)
f>>a[i];
for(int i=1;i<=n;i++)
{
best[i]=a[i];
if(best[i]<best[i-1]+a[i])
best[i]=best[i-1]+a[i];
else
inc=i;
if(bestSum<best[i])
bestSum=best[i],sf=i;
}
g<<bestSum<<" "<<inc<<" "<<sf;
return 0;
}