Pagini recente » Cod sursa (job #2540000) | Cod sursa (job #727284) | Borderou de evaluare (job #2074057) | Cod sursa (job #3232367) | Cod sursa (job #1251511)
#include<fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int a,leg[6000001],n,i,best=-999999,poz,maxi=-999999,pmaxi;
int main()
{
f>>n;
for(i=1;i<=n;++i)
{
f>>a;
if(best+a<a)
{
best=a;
leg[i]=1;
}
else
{
best+=a;
leg[i]=leg[i-1]+1;
}
if(best>maxi)
{
maxi=best;
pmaxi=i;
}
// g<<i<<" "<<best<<" "<<poz<<'\n';
}
//for(i=1;i<=n;++i) g<<leg[i]<<" ";
g<<maxi<<" ";
g<<pmaxi-leg[pmaxi]+1<<" ";
g<<pmaxi<<'\n';
return 0;
}