Cod sursa(job #983810)
| Utilizator | Data | 12 august 2013 19:10:28 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.52 kb |
#include <iostream>
#include <fstream>
#define nmax 6000005
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
int n,x,dp[nmax],maxim,pozi,pozf;
int main()
{
in >> n;
for (int i=1; i<=n; i++){
in >> x;
for (int j=1; j<=i; j++){
dp[j]+=x;
if (dp[j]>maxim) {
maxim=dp[j];
pozi=j;
pozf=i;
}
}
}
out << maxim << " " << pozi << " " << pozf;
return 0;
}
