Pagini recente » Cod sursa (job #1039413) | Cod sursa (job #1326560) | Cod sursa (job #1347133) | Cod sursa (job #2402436) | Cod sursa (job #2257653)
#include <bits/stdc++.h>
#include <climits>
#define inf (int)(INT_MAX-1)
std::ifstream InFile("ssm.in");
std::ofstream OutFile("ssm.out");
int indStart = 1, indEnd,
Max = -inf, Best = -inf;
void DP() {
int N, x, i = 0; InFile >> N;
indEnd = N;
while(N--) {
i++;
InFile >> x;
if(x >= Best+x) {
indStart = i;
Best = x;
}
else Best = Best+x;
if(Best >= Max) {
indEnd = i;
Max = Best;
}
} OutFile << Max << ' ' << indStart << ' ' << indEnd << '\n';
}
int main()
{
DP();
return 0;
}