Pagini recente » Cod sursa (job #1861161) | Cod sursa (job #262680) | Cod sursa (job #1755842) | Cod sursa (job #3277874) | Cod sursa (job #2640882)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
const int nMax = 6000005;
int n, spActual, x;
int main(){
//ifstream fin("date.in");
ifstream fin("ssm.in");
ofstream fout("ssm.out");
fin >> n;
fin >> spActual;
int bestSum = 0, minn = 0, incp = 0, sf_secv = 1, incp_secv = 0;
for(int i = 2; i <= n; ++i){
fin >> x;
spActual += x;
if(bestSum < spActual - minn){
sf_secv = i;
incp_secv = incp + 1;
bestSum = spActual - minn;
}
if(spActual < minn){
minn = spActual;
incp = i;
}
}
fout << bestSum << " " << incp_secv << " " << sf_secv << "\n";
return 0;
}