Pagini recente » Cod sursa (job #210609) | Cod sursa (job #928958) | Cod sursa (job #1867588) | Cod sursa (job #1486482) | Cod sursa (job #516102)
Cod sursa(job #516102)
#include<fstream>
#define NM 6000001
using namespace std;
ifstream in("ssmax.in");
ofstream out("ssmax.out");
int n,v[NM];
int main(){
int i,j,smax,sc,first=0,last=0;
in>>n;
for(i=1;i<=n;++i)
in>>v[i];
smax=INT_MIN;
for(i=1;i<=n;++i){
sc=0;
for(j=i;j<=n;++j){
sc+=v[j];
if(sc>smax){
smax=sc;
first=i;
last=j;
}
}
}
out<<smax<<" "<<first<<" "<<last;
return 0;
}