Cod sursa(job #2124275)
Utilizator | Data | 7 februarie 2018 08:15:37 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
#include <climits>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int x,st,dr,s,max1,min1,i,n,stt;
int main()
{
f>>n;
min1=x;
max1=x;
for(i=2;i<=n;i++)
{f>>x;
s=s+x;
if(s<min1){min1=s;st=i+1;}
if(s-min1>max1){max1=s-min1;stt=st;dr=i;}
}
g<<max1<<" "<<stt<<" "<<dr;
return 0;
}