Pagini recente » Cod sursa (job #2071906) | Cod sursa (job #1938851) | Cod sursa (job #2291756) | Cod sursa (job #292451) | Cod sursa (job #2642950)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int n, k, nr, v[50005];
int main(){
ifstream fin("secv2.in");
ofstream fout("secv2.out");
fin >> n >> k;
int maxx, posMax, minn, posMin;
for(int i = 1; i <= n; ++i){
fin >> nr;
v[i] += v[i-1] + nr;
if(maxx < v[i]){
maxx = v[i];
posMax = i;
}
if(minn > v[i]){
minn = v[i];
posMin = i+1;
}
}
fout << posMin << " " << posMax << " " << v[posMax] - v[posMin-1];
return 0;
}