Pagini recente » Cod sursa (job #177241) | Cod sursa (job #2326313) | Cod sursa (job #1491127) | Cod sursa (job #977886) | Cod sursa (job #2640881)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
const int nMax = 6000005;
long long spActual, nr, minSecv, maxSecv;
int n, pozMinSecv, pozMaxSecv;
int main(){
//ifstream fin("date.in");
ifstream fin("ssm.in");
ofstream fout("ssm.out");
fin >> n;
fin >> spActual;
minSecv = spActual;
maxSecv = spActual;
pozMaxSecv = 1;
pozMinSecv = 1;
for(int i = 2; i <= n; ++i){
fin >> nr;
spActual += nr;
if(minSecv > spActual){
minSecv = spActual;
pozMinSecv = i;
}
if(maxSecv < spActual){
maxSecv = spActual;
pozMaxSecv = i;
}
// cout << minSecv << " " << maxSecv << " " << spActual << "\n";
}
// cout << pozMinSecv << "\n";
if(pozMinSecv == 1)
fout << maxSecv << " " << 1 << " " << n;
else
fout << maxSecv - minSecv << " " << pozMinSecv + 1<< " " << pozMaxSecv<< "\n";
return 0;
}