Pagini recente » Rezultatele filtrării | Rezultatele filtrării | Rezultatele filtrării | Rezultatele filtrării | Cod sursa (job #2813370)
#include <iostream>
#include <fstream>
using namespace std;
#define INF -2000
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 = 1;
}else{
sc+=x;
}
if(sc > smax){
smax = sc;
stmax = st;
drmax = i;
}
}
fout << smax << " " << stmax << " " << drmax;
fin.close();
fout.close();
return 0;
}