Cod sursa(job #2124284)
Utilizator | Data | 7 februarie 2018 08:19:56 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 65 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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=INT_MAX;
max1=-99999999;
for(i=1;i<=n;i++)
{f>>x;
s=s+x;
if(s-min1>max1){max1=s-min1;stt=st;dr=i;}
if(s<min1){min1=s;st=i+1;}
}
g<<max1<<" "<<stt<<" "<<dr;
return 0;
}