Pagini recente » Cod sursa (job #3265868) | Cod sursa (job #3235856) | Cod sursa (job #3232918) | Cod sursa (job #667994) | Cod sursa (job #3237996)
#include <bits/stdc++.h>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int n;
long long x, smax, curent, ST, DR, st;
int main()
{
f >> n >> x;
smax = curent = x;
st = ST = DR = 1;
for(int i = 2; i<=n; i++)
{
f >> x;
if(curent + x > x)
curent += x;
else
curent = x, st = i;
if(curent > smax)
smax = curent, ST = st, DR = i;
}
g << smax<<" "<<ST<<" "<< DR;
}