Pagini recente » Cod sursa (job #1935343) | Cod sursa (job #1644119) | Cod sursa (job #1474898) | Statistici Lupascu Miruna-Stefania (MirunaStefania) | Cod sursa (job #1894978)
#include <fstream>
#include <queue>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int i, n, x, l, r, best[40000], best_max;
int main()
{
fin >> n;
for(i = 1; i <= n; i++)
{
fin >> x;
best[i] = x;
if(best[i] < best[i-1] + x)
best[i] = best[i-1] + x;
if(best_max < best[i])
best[i] = best_max;
}
fout << best_max;
return 0;
}