Pagini recente » Cod sursa (job #2578927) | Cod sursa (job #1413203) | Cod sursa (job #1237099) | Cod sursa (job #1673273) | Cod sursa (job #2845480)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
ifstream f ("ssm.in");
ofstream g ("ssm.out");
int n; f >> n;
ll ant = 0;
ll mx = 0;
ll now = 0;
int st, stmx, drmx;
for(int i=1; i<=n; i++) {
ll x; f >> x;
if(x>ant+x) {
now = x;
ant = x;
st = i;
}
else {
now = ant + x;
ant = now;
}
if(now > mx) {
mx = now;
stmx = st;
drmx = i;
}
}
g << mx << " " << stmx << " " << drmx;
return 0;
}