Pagini recente » Cod sursa (job #410971) | Cod sursa (job #1548570) | Cod sursa (job #305938) | Cod sursa (job #1142969) | Cod sursa (job #2163006)
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int x,n,i,st,dr,stmax,drmax,best[6000001];
long long smax;
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;
}