Cod sursa(job #1918962)
Utilizator | Data | 9 martie 2017 17:31:56 | |
---|---|---|---|
Problema | Subsecventa de suma maxima | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
long long s, S;
int n, i, j, x, st, dr, in;
int main()
{
f >> n;
for(i=1;i<=n;i++)
{
if(s<0){
s=0;
in=i;
}
f >> x;
s=s+x;
if(s>S){
S=s;
st=in;
dr=i;
}
}
g << S << " " << st << " " << dr << '\n';
return 0;
}