Pagini recente » Cod sursa (job #2749361) | Cod sursa (job #3209606) | Cod sursa (job #819182) | Cod sursa (job #2385534) | Cod sursa (job #2939903)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int main()
{
int i,b,c,n,max;fin>>n>>max;int DP[n+1];DP[0]=max;
for(i=1;fin>>DP[i];++i){
if(DP[i-1]>0)DP[i]+=DP[i-1];
else b=i+1;DP[i-1]=DP[i];
if(max<DP[i]){max=DP[i];c=i+1;}
}
fout<<max<<' '<<b<<' '<<c;
return 0;
}