Mai intai trebuie sa te autentifici.
Cod sursa(job #2138347)
| Utilizator | Data | 21 februarie 2018 16:19:48 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 95 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int i,n,v[6000000],best[6000000],maxx=-999999999,poz,p;
int main()
{
cout<<(float)sizeof(v)/1024/1024;
f>>n;
for(i=1; i<=n; i++)
{
f>>v[i];
if(v[i]<v[i]+best[i-1])
best[i]=v[i]+best[i-1];
else
best[i]=v[i];
if(best[i]>maxx)
{
maxx=best[i];
poz=i;
}
}
p=poz;
while(p>0 and best[p]>=0)
p--;
g<<best[poz]<<" "<<p+1<<" "<<poz;
}
