Pagini recente » Cod sursa (job #2900083) | Cod sursa (job #1687186) | Cod sursa (job #65936) | Cod sursa (job #3138162) | Cod sursa (job #2813375)
#include <iostream>
#include <fstream>
using namespace std;
#define INF 20000000000
int main()
{
ifstream fin("ssm.in");
ofstream fout("ssm.out");
long long n;
fin >> n;
long long sc = -1;
long long smax = -INF;
long long st = 1;
long long stmax, drmax;
for(long long i = 1; i <= n; i++){
long long x;
fin >> x;
if(sc < 0){
sc = x;
st = i;
}else{
sc+=x;
}
if(sc > smax){
smax = sc;
stmax = st;
drmax = i;
}
}
fout << smax << " " << stmax << " " << drmax;
fin.close();
fout.close();
return 0;
}